From patchwork Thu Oct 28 04:43:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1547313 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=npCn/hGc; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=sd9NPyJ3; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HftPb0zS8z9sP7 for ; Thu, 28 Oct 2021 15:49:07 +1100 (AEDT) Received: from localhost ([::1]:54520 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfxLc-0004wA-SR for incoming@patchwork.ozlabs.org; Thu, 28 Oct 2021 00:49:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50648) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxGk-0007gR-8c for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:44:02 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:41707) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxGi-0001s5-6S for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:44:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1635396240; x=1666932240; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Flu3ImfJDOuc4S17tyTyOmKZ2MobboLwiyCkPnQM2PE=; b=npCn/hGcVtI+4SOBreRvrgPm2tXNAdoj2WkaPtEYQ/l6bAmB3goqvKPe J8iP0hYkZiZXrBAt+usKrMKst4JV0AeJosPGPikSSYJ1KVGX2+GmLmLqw 0Vp3DTZdlvGdct63XGPdpJPmS+qVR11IlKFXxcmljdE1AiMQ74L/r1/2I R+YZUGDkreRjUZDcJ+Qaqj2FFLNlLW888tlWkmexo5cPJCF4FegYg0Kuz 7qGaTtJrtwr0Lrvisj/EH+gG+VKaS2olFu7yfuclz8d3T2FvZqZ128ftr AEEBR4dS9rexv/mR9HzCh5fPghELRPCBybB+6KTJy+jaNT9/ouBu25Fzv A==; X-IronPort-AV: E=Sophos;i="5.87,188,1631548800"; d="scan'208";a="184975467" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 28 Oct 2021 12:43:59 +0800 IronPort-SDR: 1tTR+hA1/+yE37glzw/luHD2Tfs+ZDl3NF8/lIEqgLeeJL95t29YCZ8YJI61j2xR3k5jJsGomr VVc6XW+XLxLdsvaGbJV/5oNG83lJD8vmsIgry6LXo0LX2HjyMBF484xfU+uOy9xYLDD+9970zv 5BCXImsVrX/t/uVgsxB8w4EheVn+v77TDn4jgA82pHa3etX97rMhGaZ0OGDfCuisfI/tuSA51G SDMOnCTuTbq0uoHOMRsgV07RnXEnHfwz/qOuqQCpacCtzkTCekh4dbvDX6Iy6+bROnn6HHMgp9 16KrW/ZZBGiB+ZVEk+6sCoAw Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:17:54 -0700 IronPort-SDR: IXV6mEfuA6iUbhXeVrWFDpglpgazuXMGFASEruG3fpphT29+UrISqs48W+VqxP7skRCFeRTnq1 eKpIE2Nxoaz/IG3idtPTgmJ4m7QnxwZ7q8Z2X+jNfr2d/5s1j/oY4MqEfFUw7tDuaqfIeRrcCI VkFkfsYDI9JC7PBYwWtzutlcaoVBxh3Zb9u5hbu6r4F5kLzNrprwX3vQugdDeai7/CXMLukleg vW4pg8kiSXx2VgEDVMZbs2o1hTSyJJy6EJDYz5g1/2GHVex8vWbrg75/MfMf0kF5HEeufEp/jH 8jY= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:43:59 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HftHf5HnRz1RtVv for ; Wed, 27 Oct 2021 21:43:58 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :mime-version:references:in-reply-to:x-mailer:message-id:date :subject:to:from; s=dkim; t=1635396238; x=1637988239; bh=Flu3Imf JDOuc4S17tyTyOmKZ2MobboLwiyCkPnQM2PE=; b=sd9NPyJ3T2fxjIJKouibqJR HyIiCs1wDacBcyDlqjZa+Oty757Mw3kQklVTnAHY8hsSnmthpiXrtEP9LYeQr63a khYfMMn6mmqv2aNPniTte/6Oc28oFgL1YUMEiUqxpA7fhHNsfb3cYL9tY71SD8tT xraWMozDhfU9QC6WEwClcShPr0bzFFjHc/JUs8Hb/spd5+M1VcxUGVutzWS/No5p csWK5D8my0XnZu/V1duTHi0f9E4WP2+Ryr9CYMH+i5F2geamDaDsf8MD3LtBjcpq OUmp2PeL64RDpqc+zLfaCp4c0pldmjcM2pcV0Q9dU/GWtiRElXf+5pmBIBizgAA= = X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id WkdFKpt_wIRQ for ; Wed, 27 Oct 2021 21:43:58 -0700 (PDT) Received: from toolbox.alistair23.me (unknown [10.225.165.40]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HftHZ28X3z1RtVl; Wed, 27 Oct 2021 21:43:53 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Alistair Francis , Bin Meng , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 01/18] hw/riscv: virt: Don't use a macro for the PLIC configuration Date: Thu, 28 Oct 2021 14:43:25 +1000 Message-Id: <20211028044342.3070385-2-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> References: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=928ee31ee=alistair.francis@opensource.wdc.com; helo=esa6.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alistair Francis Using a macro for the PLIC configuration doesn't make the code any easier to read. Instead it makes it harder to figure out what is going on, so let's remove it. Signed-off-by: Alistair Francis Reviewed-by: Bin Meng Reviewed-by: Philippe Mathieu-Daudé Message-id: 20211022060133.3045020-1-alistair.francis@opensource.wdc.com --- include/hw/riscv/virt.h | 1 - hw/riscv/virt.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/include/hw/riscv/virt.h b/include/hw/riscv/virt.h index d9105c1886..b8ef99f348 100644 --- a/include/hw/riscv/virt.h +++ b/include/hw/riscv/virt.h @@ -73,7 +73,6 @@ enum { VIRTIO_NDEV = 0x35 /* Arbitrary maximum number of interrupts */ }; -#define VIRT_PLIC_HART_CONFIG "MS" #define VIRT_PLIC_NUM_SOURCES 127 #define VIRT_PLIC_NUM_PRIORITIES 7 #define VIRT_PLIC_PRIORITY_BASE 0x04 diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index b3b431c847..28a5909a3b 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -758,7 +758,7 @@ static char *plic_hart_config_string(int hart_count) int i; for (i = 0; i < hart_count; i++) { - vals[i] = VIRT_PLIC_HART_CONFIG; + vals[i] = "MS"; } vals[i] = NULL; From patchwork Thu Oct 28 04:43:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1547310 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=Ql9drBhT; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=MhWNr9+R; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HftKD5LXVz9sP7 for ; Thu, 28 Oct 2021 15:45:20 +1100 (AEDT) Received: from localhost ([::1]:46580 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfxHy-0007lW-GK for incoming@patchwork.ozlabs.org; Thu, 28 Oct 2021 00:45:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxGo-0007k2-JQ for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:44:06 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:41715) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxGm-00027Z-Jd for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:44:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1635396244; x=1666932244; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wGyIdKI9dEPN8wPZ1iUdWigMHa8SpOE+exKfNqVyO4w=; b=Ql9drBhT384Lwh/uH56raQldt/RZ9FWpJ/KCgOU6QEjY2A/WpV/SMHKr 5D9TsMdehhXCsoAdmUqQ2/1lIJA5nAfwPbQymOI/xXFXHRR40e6/Ko+SC lOaC2nNXTJ7i9zaJXqwf+65pBS1tDO4ZgDZDMfTfUqwkGOkJTxVtuEWcW F7dWDmxqO6bayeeQ4f5MeB0jXLJFEKWMvOOuCr3zE6ysKe1Ro9ve5zFvx viGioYwGjQtZHwjdrLz6IlFHvgYo0cAYnPVHQ7MmJlt07LsE1AAe93Pfx VUA04iTctLTAOmrh96BaDrReGA4hG9uj81SMbLW1n/sBi7ynL5J/PCMqQ w==; X-IronPort-AV: E=Sophos;i="5.87,188,1631548800"; d="scan'208";a="184975475" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 28 Oct 2021 12:44:03 +0800 IronPort-SDR: uUACh98pLmEhX7ElZTmw5DjzQ16QRdqXqOABQWRrah7vAXPpldNKDTIEZt09InCz+8zSbiNDq+ AHCzzX+0FdfwFakdZ8leZO9/yPYK6mX3JRw4Zuwh/Iw6lrolsQmzodPwOrKHC96SBncmxga9YI +4eqZUL4pRsLh0rnaOcHMfxLcr/cMhPJimLogQ+VWBJQ6MQ9jzX1m3UqB/bcgCEW3cyL72dhtL fIfkammIVJhBnEKuEX7cG0Pqp85jOB8CPJJC6l5C4TnF8tz0TbfjPNlkyyaA+2wgY7ZqsFA0IE 7yFvZT1uFaPx7yI/fnTOyXbJ Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:17:58 -0700 IronPort-SDR: a3zZ3otR6zIW2XahT3GsKl5qpckUfa9uWXamCsddLbHb2TXowcUCZA1HQ3ldYSQqjO79hTIy4p ONVYd7FX0drbQI7WWRf4XBlxYDdV6y/8Y8N43u26QCHgEOZPq/SGU2pmYDuUlUIiasLqOhQJhn kwnxH5KoBF77y8yOn10xO2opdkSzPlvpl51ULOeugcMamzk14/QsodlQ+NudgqKktXfreBIZRk uiekthByG34+Nu55FN295Lqp2Pz18ltb8BpOCDz6JRNnZugEesLEdXEF7z/N48MruBg+E1u94G Qfk= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:44:03 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HftHl1FxXz1RtVm for ; Wed, 27 Oct 2021 21:44:03 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :mime-version:references:in-reply-to:x-mailer:message-id:date :subject:to:from; s=dkim; t=1635396242; x=1637988243; bh=wGyIdKI 9dEPN8wPZ1iUdWigMHa8SpOE+exKfNqVyO4w=; b=MhWNr9+Rq9EK4XAgDsGmXcG uhB+M8uPPmXfmnNXvDjrnHidRvI3b1AG1LQuAYaZSJsbUQgGfuaotTSx5yEVznxB dNZMxiGziyiMTd2849jhKUpsIETk0rAko0rKsxHLbv7eDDbu+HanvJzpfsBOc/jN ZyR0eScmi92LgA/10THh4p4E7SwOaNOzATHGUXN2UGTO10H28kSuOYyziFF/sgEL 2R91bZE0A0tO6bgV5Fi2hz7WlB8zleiKdVoOfrFNZx+1Uj7UgYL338Jq49ZLXAGY A9dNxH+YStIC0PK5z8V++AsgbYKg+k0f/qFlqEDNederKpGcrtC5fqrJtEGwifA= = X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id uqeU_WL5Z2_H for ; Wed, 27 Oct 2021 21:44:02 -0700 (PDT) Received: from toolbox.alistair23.me (unknown [10.225.165.40]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HftHg22FLz1RtVl; Wed, 27 Oct 2021 21:43:58 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Alistair Francis , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bin Meng Subject: [PULL 02/18] hw/riscv: boot: Add a PLIC config string function Date: Thu, 28 Oct 2021 14:43:26 +1000 Message-Id: <20211028044342.3070385-3-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> References: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=928ee31ee=alistair.francis@opensource.wdc.com; helo=esa6.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alistair Francis Add a generic function that can create the PLIC strings. Signed-off-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Bin Meng Message-id: 20211022060133.3045020-2-alistair.francis@opensource.wdc.com --- include/hw/riscv/boot.h | 2 ++ hw/riscv/boot.c | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/include/hw/riscv/boot.h b/include/hw/riscv/boot.h index 0e89400b09..baff11dd8a 100644 --- a/include/hw/riscv/boot.h +++ b/include/hw/riscv/boot.h @@ -31,6 +31,8 @@ bool riscv_is_32bit(RISCVHartArrayState *harts); +char *riscv_plic_hart_config_string(int hart_count); + target_ulong riscv_calc_kernel_start_addr(RISCVHartArrayState *harts, target_ulong firmware_end_addr); target_ulong riscv_find_and_load_firmware(MachineState *machine, diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c index d1ffc7b56c..519fa455a1 100644 --- a/hw/riscv/boot.c +++ b/hw/riscv/boot.c @@ -38,6 +38,31 @@ bool riscv_is_32bit(RISCVHartArrayState *harts) return harts->harts[0].env.misa_mxl_max == MXL_RV32; } +/* + * Return the per-socket PLIC hart topology configuration string + * (caller must free with g_free()) + */ +char *riscv_plic_hart_config_string(int hart_count) +{ + g_autofree const char **vals = g_new(const char *, hart_count + 1); + int i; + + for (i = 0; i < hart_count; i++) { + CPUState *cs = qemu_get_cpu(i); + CPURISCVState *env = &RISCV_CPU(cs)->env; + + if (riscv_has_ext(env, RVS)) { + vals[i] = "MS"; + } else { + vals[i] = "M"; + } + } + vals[i] = NULL; + + /* g_strjoinv() obliges us to cast away const here */ + return g_strjoinv(",", (char **)vals); +} + target_ulong riscv_calc_kernel_start_addr(RISCVHartArrayState *harts, target_ulong firmware_end_addr) { if (riscv_is_32bit(harts)) { From patchwork Thu Oct 28 04:43:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1547314 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=jMVfh+5f; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=MiNm0ptY; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HftPz2WJqz9sP7 for ; Thu, 28 Oct 2021 15:49:27 +1100 (AEDT) Received: from localhost ([::1]:55510 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfxLw-0005lr-Dm for incoming@patchwork.ozlabs.org; Thu, 28 Oct 2021 00:49:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50790) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxH9-00082J-Eu for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:44:27 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:41715) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxGq-00027Z-UD for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:44:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1635396249; x=1666932249; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2bhE2KAm4XELUw70Wt4uFjyOwGrHqZPz8+o1YDvNMX4=; b=jMVfh+5frPo0BHcocBdpLJhBauLtx+Ra6km4V4PRC1/pc1KHGEz0LAUR VcKbcM0ENgyPAom6YgLcN6uaFSQ0WqpVN66yKgiJu6jTzLnu8bmGY7lB5 sadr6+tn2a/OeiYnNFYXgGWCiUM3BttFZ3ugXBPOr/ha5BELIKU1t3f83 e07Mj1h265QlFK1921NRmLkjpP+DcHfNK0u+UVWzTl4YaoeTdo3njTCZ1 nMLhm/erWT4PnMnhOD6O71fyMXLy+3tOqBizqZTir1Q0cZoV+LOB+GkTI MZ8QOPgcOaKq/VtoBrUiF45NrBYxDxUXqkFGQ4qn/EUDWOF2AXPWXC80Y w==; X-IronPort-AV: E=Sophos;i="5.87,188,1631548800"; d="scan'208";a="184975481" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 28 Oct 2021 12:44:08 +0800 IronPort-SDR: UEebte33cNcs30NQ5k2sD8MhWeY0buvUnySYsRgJz4wn4GfWAabCtMeRxUuo3ZBD6Cty0P6+0Y zUqhQCcrUPZaMwvi+4zHYoUVtRhdc4+fYEPKw+ugwXC/pa9dUmrq74wLVoLk7p0GJrynqVEYcl lGaFodeCn41rx7Uafg2X7wEJsAccgn8CLbC/VDs52LUoB0Slxk/Gp0wMxmHiS1kGSfRK9Rxy9a 9hjAaQ4BHgxuzrEu6jPwdjRX9evGcpZqAsa6Dsaldr+1qRVyBZogdyF/jlp3DbSWzAfhkRAzn2 8Drr1vCwNpxr5fae0C1YSyyg Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:18:03 -0700 IronPort-SDR: 3hFjp43mOltsfChAkDKlLnE3VlcIOakNnIFloAc3FIYfvDbFNXUmhhbq0ayIq1jictOES1xJuz D24x4+hGSoYw/OAwMErZuk+Ugf1wn51AlN8CxssbV5nNUHNH2eWqVBcVThj2wSM9iXfSH4Ka4A /pF2G3fwWWeXJWbtZjobjgltgMrUZj8z7Kin/DVH2OjtUl/fNGwZxbSpp95dA2OKImZ+bpeskQ K/zzDaXB65ACW0Psluc8Tkgf2GsmOIBDW0juKxj1oQF2px4CGLps4gvj+x2ejItm9vXa2wY6nd ds4= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:44:08 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HftHq6lsMz1RtVt for ; Wed, 27 Oct 2021 21:44:07 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :mime-version:references:in-reply-to:x-mailer:message-id:date :subject:to:from; s=dkim; t=1635396247; x=1637988248; bh=2bhE2KA m4XELUw70Wt4uFjyOwGrHqZPz8+o1YDvNMX4=; b=MiNm0ptYmFDI7bIqG8IgnEE MwLud8Lofaf7imOifty/bQ76SgQflxiUxOJ7Cy3i6RsVvSJ7Ty78wrwgh2CiivpY FcfwQYaxX0TNKodjjbnh8U4bdWwYbAjB8f3Is2ebCCuVUxX7N6taX7Bjt8OclcYq KjubPMSIC07wN6gTzEb5Xi/t577jC2+c37vwHEghQbUKweGUK2uvxel5IqkgswyU wEajZuKzyPwqwJm/kCLQDOetsYSd8qUnKtaa6/MeOlcZj3h4cWJLD68FjnwI4OM2 h2oVrdbN/bdai92LbbdqW7BKM6MVkJsuFdRnWGxooWWF8Z6rH2V7OYzq2cJ6k5Q= = X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Q79fKvkrHqm9 for ; Wed, 27 Oct 2021 21:44:07 -0700 (PDT) Received: from toolbox.alistair23.me (unknown [10.225.165.40]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HftHl69QSz1RtVl; Wed, 27 Oct 2021 21:44:03 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Alistair Francis , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bin Meng Subject: [PULL 03/18] hw/riscv: sifive_u: Use the PLIC config helper function Date: Thu, 28 Oct 2021 14:43:27 +1000 Message-Id: <20211028044342.3070385-4-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> References: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=928ee31ee=alistair.francis@opensource.wdc.com; helo=esa6.hgst.iphmx.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alistair Francis Signed-off-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Bin Meng Tested-by: Bin Meng Message-id: 20211022060133.3045020-3-alistair.francis@opensource.wdc.com --- include/hw/riscv/sifive_u.h | 1 - hw/riscv/sifive_u.c | 14 +------------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h index f71c90c94c..8f63a183c4 100644 --- a/include/hw/riscv/sifive_u.h +++ b/include/hw/riscv/sifive_u.h @@ -156,7 +156,6 @@ enum { #define SIFIVE_U_MANAGEMENT_CPU_COUNT 1 #define SIFIVE_U_COMPUTE_CPU_COUNT 4 -#define SIFIVE_U_PLIC_HART_CONFIG "MS" #define SIFIVE_U_PLIC_NUM_SOURCES 54 #define SIFIVE_U_PLIC_NUM_PRIORITIES 7 #define SIFIVE_U_PLIC_PRIORITY_BASE 0x04 diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index 0217006c27..589ae72a59 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -811,7 +811,6 @@ static void sifive_u_soc_realize(DeviceState *dev, Error **errp) MemoryRegion *mask_rom = g_new(MemoryRegion, 1); MemoryRegion *l2lim_mem = g_new(MemoryRegion, 1); char *plic_hart_config; - size_t plic_hart_config_len; int i, j; NICInfo *nd = &nd_table[0]; @@ -852,18 +851,7 @@ static void sifive_u_soc_realize(DeviceState *dev, Error **errp) l2lim_mem); /* create PLIC hart topology configuration string */ - plic_hart_config_len = (strlen(SIFIVE_U_PLIC_HART_CONFIG) + 1) * - ms->smp.cpus; - plic_hart_config = g_malloc0(plic_hart_config_len); - for (i = 0; i < ms->smp.cpus; i++) { - if (i != 0) { - strncat(plic_hart_config, "," SIFIVE_U_PLIC_HART_CONFIG, - plic_hart_config_len); - } else { - strncat(plic_hart_config, "M", plic_hart_config_len); - } - plic_hart_config_len -= (strlen(SIFIVE_U_PLIC_HART_CONFIG) + 1); - } + plic_hart_config = riscv_plic_hart_config_string(ms->smp.cpus); /* MMIO */ s->plic = sifive_plic_create(memmap[SIFIVE_U_DEV_PLIC].base, From patchwork Thu Oct 28 04:43:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1547311 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=NN5eI0U5; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=eHV53gA4; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HftKM0lwkz9sP7 for ; Thu, 28 Oct 2021 15:45:26 +1100 (AEDT) Received: from localhost ([::1]:46806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfxI3-0007uv-Iw for incoming@patchwork.ozlabs.org; Thu, 28 Oct 2021 00:45:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50742) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxGy-0007qO-RK for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:44:19 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:41722) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxGx-0002ce-7f for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:44:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1635396255; x=1666932255; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KEw5q9HNzhkql2zKkXPMJiqfgwFvkdBfp9K+I2P679s=; b=NN5eI0U5hOKiXNCqawtH70FwkQSxHo6C1A7uOSgkmPiCXsoTllYiQx85 mIdJO74jqKH7/ft9bi0uC5bileKY4q2WnaBVriG2ax6mFXM1DJ+pUWJM2 EoqOySR2CAWNL0vpDF0b5+siJ+7BZytSNDKdIiREF5VIKjE031+FQtxbT F+2lTfl3l7513WVYeP88uk9rHCIFsdma5e8tkLIb4qpC/RTxDMA2ufZ/d gMbpYuS2lOQKVRhNGcS2Acf/7n6tsDub1C8TjBJ1pddwKt3Ro10oUoFeO OdTbQLvyoHdGFsZ80wPpxcq4XLYWiLndZEz22Um3HGQivX7D1YmbRyJ8N w==; X-IronPort-AV: E=Sophos;i="5.87,188,1631548800"; d="scan'208";a="184975485" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 28 Oct 2021 12:44:13 +0800 IronPort-SDR: HWEq5ri6s81yNlsA+YpeUmHeBm9HR+FQHvpKbZky3UE42r5h4xVqzLPDExtFqQxIgMuwmr5kHp Pf4MXkmekUZtoTLT2743UxMvTKEajaZVr44YnulkTZEOR8em3A2WvR6sALkBtzbKMl0zLh/dZv 60dJ5QyGqs/gSQmnBAIy20/+kSi694dcWqLG6//hcH1neJYiGUXkEbk0NOR7HKYMCHE+p8MW/Q vbPdpQdVE1lE5HdayP+aEZjOh6gXKZf7zjnPKvLDHf+f6BBvmaXEc2/9yxA2FF+NlEeBNTIzJV 1EKULkWOVnPxXG4p1GRHgh3N Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:18:08 -0700 IronPort-SDR: ZrZhDryOH03oQzhJCwO9MNhruzKHbTvT1fzwe/P7N/YTDfM6HYqnLZ8TYbrDOzDpyPhWJ9qFkm 7zjJtfKyaICTC4EqnfZLXWpH5xzs3QxACHqUKW+X8AKRwa0AHFd9MAHMTvaJwoMgja8JT6snXe nmTY1IhyhIJhp7nq7rlHhgaYWPCxm9Ygm7jCOKYUurqLAGtZAHjVZ0qlBV+Y9Xc1PoComWTGU9 whe6jjlpLdF7ciwHlz8gS09VwuRuwe4Q+0G801BDMLbH/bxgFhmN+YZUF5oH8laQ0GzeKW/UfD pP0= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:44:13 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HftHw6lSJz1RtVp for ; Wed, 27 Oct 2021 21:44:12 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :mime-version:references:in-reply-to:x-mailer:message-id:date :subject:to:from; s=dkim; t=1635396252; x=1637988253; bh=KEw5q9H Nzhkql2zKkXPMJiqfgwFvkdBfp9K+I2P679s=; b=eHV53gA4BKJxsSl1MruIPVK PQgKSc/Q+WZtQYXwg7pUbEskVBMoJxkP3oiRbvno9MNKNLOO4OSYXOlq1ckkpSx/ Xn1ZcjlXGnRyWgGITqyTFmZDCY3eDwwVdB2yzdMv43Y48iApqDemEPpx8JgMKurC DdtXcZV1JkwvKttts9TkxGVSNTeCEwB/4ow/GtFMbpDKdtCKaXK3YbRbWTnpPH4d Ska2o5X9UkDrmHzUSuBW1MUmCvBPbfem+MARgWLfD0ZfB5jw1k1ZV2YdwuRnEmrL ke2szETHuLrVWFmiX5Rb033VZPiDR4NRSBkZ4dM2kZaWGfaKvwIlNxM9kFhIRXg= = X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id XnsFDBuLVHp1 for ; Wed, 27 Oct 2021 21:44:12 -0700 (PDT) Received: from toolbox.alistair23.me (unknown [10.225.165.40]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HftHr3nx6z1RtVl; Wed, 27 Oct 2021 21:44:08 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Alistair Francis , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bin Meng Subject: [PULL 04/18] hw/riscv: microchip_pfsoc: Use the PLIC config helper function Date: Thu, 28 Oct 2021 14:43:28 +1000 Message-Id: <20211028044342.3070385-5-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> References: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=928ee31ee=alistair.francis@opensource.wdc.com; helo=esa6.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alistair Francis Signed-off-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Bin Meng Tested-by: Bin Meng Message-id: 20211022060133.3045020-4-alistair.francis@opensource.wdc.com --- include/hw/riscv/microchip_pfsoc.h | 1 - hw/riscv/microchip_pfsoc.c | 14 +------------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/include/hw/riscv/microchip_pfsoc.h b/include/hw/riscv/microchip_pfsoc.h index d30916f45d..a0673f5f59 100644 --- a/include/hw/riscv/microchip_pfsoc.h +++ b/include/hw/riscv/microchip_pfsoc.h @@ -138,7 +138,6 @@ enum { #define MICROCHIP_PFSOC_MANAGEMENT_CPU_COUNT 1 #define MICROCHIP_PFSOC_COMPUTE_CPU_COUNT 4 -#define MICROCHIP_PFSOC_PLIC_HART_CONFIG "MS" #define MICROCHIP_PFSOC_PLIC_NUM_SOURCES 185 #define MICROCHIP_PFSOC_PLIC_NUM_PRIORITIES 7 #define MICROCHIP_PFSOC_PLIC_PRIORITY_BASE 0x04 diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c index 3fc8545562..57d779fb55 100644 --- a/hw/riscv/microchip_pfsoc.c +++ b/hw/riscv/microchip_pfsoc.c @@ -187,7 +187,6 @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp) MemoryRegion *envm_data = g_new(MemoryRegion, 1); MemoryRegion *qspi_xip_mem = g_new(MemoryRegion, 1); char *plic_hart_config; - size_t plic_hart_config_len; NICInfo *nd; int i; @@ -262,18 +261,7 @@ static void microchip_pfsoc_soc_realize(DeviceState *dev, Error **errp) l2lim_mem); /* create PLIC hart topology configuration string */ - plic_hart_config_len = (strlen(MICROCHIP_PFSOC_PLIC_HART_CONFIG) + 1) * - ms->smp.cpus; - plic_hart_config = g_malloc0(plic_hart_config_len); - for (i = 0; i < ms->smp.cpus; i++) { - if (i != 0) { - strncat(plic_hart_config, "," MICROCHIP_PFSOC_PLIC_HART_CONFIG, - plic_hart_config_len); - } else { - strncat(plic_hart_config, "M", plic_hart_config_len); - } - plic_hart_config_len -= (strlen(MICROCHIP_PFSOC_PLIC_HART_CONFIG) + 1); - } + plic_hart_config = riscv_plic_hart_config_string(ms->smp.cpus); /* PLIC */ s->plic = sifive_plic_create(memmap[MICROCHIP_PFSOC_PLIC].base, From patchwork Thu Oct 28 04:43:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1547316 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=Q1vYVciy; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=lNy7Te/0; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HftTx0Jzyz9sP7 for ; Thu, 28 Oct 2021 15:52:53 +1100 (AEDT) Received: from localhost ([::1]:32826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfxPG-0001LO-RM for incoming@patchwork.ozlabs.org; Thu, 28 Oct 2021 00:52:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50774) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxH4-0007xy-Bj for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:44:22 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:41722) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxH0-0002ce-TM for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:44:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1635396259; x=1666932259; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+Af7wKlpUvnUSPSXLQm3DK7gy4CQ7wIfbpuX3QPuLXE=; b=Q1vYVciyIEOxTpK2L6vLJEBMBFbGT/ZX06HH9I4t1lzpSZ5Xugt6bQ8Q hVdNGf+1yKCkSZMYkscbmzaHmcLGyG8M1efrUskhADJ9xj4KUbRFpo+6F ItCyp/Mz61skrPLomxeatLsLyZq9sKJGkUTWhIKCt4kjZYmUKeddNQ6jR e+D3LygNCKcBHecPvDG14qEmL7eToBKbB+Db6MGvFn8erLSN/hJoiBwtC 9yNqG6qKXi1yW5qEHEQrpzKRbJHBdtVjfId5kSfLzW3BhOi4Z+iguRAuy YJAINNuvnTDMq28EybOMZt3VY8UzhwxfJo2XOPn1UzGVBPo5saJoZz3b/ A==; X-IronPort-AV: E=Sophos;i="5.87,188,1631548800"; d="scan'208";a="184975497" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 28 Oct 2021 12:44:18 +0800 IronPort-SDR: BEPfRaPgr5mTov+zF86NkBY4Rz7PCvXSeIRlwpZj2TPPBww1M+uvVthkUL1IyuMPo49QvVruT9 r4BlYjWIpaV9AgqhAo8uDqW6XXx+Vt7gRQEOlYiiQom9Jr7pfKAjxDUycuiux4r7DBtrpfJMRA 2NX3G+ckj9OSwr5bzGnqpL3Usep3cmUJxAVR4Q8UzQpKe2zAISnyE0JPH73EvsxWZrT9tNOuIu NKbQAIsJ1roN3zQ9uk0cVZl7A7qZumZc4c6PainN0ftlBDOHUDDZr5Jfy46w39igtjE2vg8IJq vJg+iDc6tjUC/8AQODJKMXkC Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:18:13 -0700 IronPort-SDR: lQryMSlC+jn3XT4WOWpVuHPigZL+R8o7L383IdzVCmlBlhyc1dK2PaQVCPpNEUALN9mSOIKj1X fNbvW0G+E2HptRYFOAV6WO0qJGfcbzXR7d67VPS+usYjpQCElzttymjOo8CigiZMqgs0ZXoWTJ uYGEGAlmjWgIUbhaTjo3Mang4r63kKJaBKWEbL+8x4rs7D3Ip51mlX5/tOEb262DaXl75zVy70 uzkpe8f4a4LwJDgTt28oT4ubOBV8XFq5E09mXqYftpXVYd56vd0BZXSXpFZykgmTdves042cOG OuY= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:44:18 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HftJ15cMmz1RtVn for ; Wed, 27 Oct 2021 21:44:17 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :mime-version:references:in-reply-to:x-mailer:message-id:date :subject:to:from; s=dkim; t=1635396257; x=1637988258; bh=+Af7wKl pUvnUSPSXLQm3DK7gy4CQ7wIfbpuX3QPuLXE=; b=lNy7Te/0WWHm2OnNbKrzIbr oKfr5Rt2LxE0fo/UFhCsKVALdjWwOm0Lepy9miXyXtdAgJv6Ks+Co9RmjorU2SfV 11BemrL9jaAzzNFJR6AnVZpagm+Q55kQPd2iOBBSqLKqvyInFS5QkO7CI3KH3UKD y4tzine4VHHMYIxcs6CR5kiRB+IpvY+8SnntCzd1FajpVt6K8vibJPBGVqoTWpHO r8yy2pJdGRwgJSO9TUX2kD0bjoMhy82IG8DMT8TxT9AssMtu5/Tg1AvfkXMKgPLi jOJo3DBGOdv5QNCUodYr7djSeD9ezg85gm/sMZqwCb8fkd/VZyT2rbh/Opwqh4g= = X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id T8dOE_BZ5Pcv for ; Wed, 27 Oct 2021 21:44:17 -0700 (PDT) Received: from toolbox.alistair23.me (unknown [10.225.165.40]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HftHx37Qwz1RtVl; Wed, 27 Oct 2021 21:44:12 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Alistair Francis , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bin Meng Subject: [PULL 05/18] hw/riscv: virt: Use the PLIC config helper function Date: Thu, 28 Oct 2021 14:43:29 +1000 Message-Id: <20211028044342.3070385-6-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> References: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=928ee31ee=alistair.francis@opensource.wdc.com; helo=esa6.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alistair Francis Signed-off-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Bin Meng Tested-by: Bin Meng Message-id: 20211022060133.3045020-5-alistair.francis@opensource.wdc.com --- hw/riscv/virt.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 28a5909a3b..3af074148e 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -748,24 +748,6 @@ static FWCfgState *create_fw_cfg(const MachineState *mc) return fw_cfg; } -/* - * Return the per-socket PLIC hart topology configuration string - * (caller must free with g_free()) - */ -static char *plic_hart_config_string(int hart_count) -{ - g_autofree const char **vals = g_new(const char *, hart_count + 1); - int i; - - for (i = 0; i < hart_count; i++) { - vals[i] = "MS"; - } - vals[i] = NULL; - - /* g_strjoinv() obliges us to cast away const here */ - return g_strjoinv(",", (char **)vals); -} - static void virt_machine_init(MachineState *machine) { const MemMapEntry *memmap = virt_memmap; @@ -839,7 +821,7 @@ static void virt_machine_init(MachineState *machine) } /* Per-socket PLIC hart topology configuration string */ - plic_hart_config = plic_hart_config_string(hart_count); + plic_hart_config = riscv_plic_hart_config_string(hart_count); /* Per-socket PLIC */ s->plic[i] = sifive_plic_create( From patchwork Thu Oct 28 04:43:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1547317 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=I/cMqDNU; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=IJtbyPKY; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HftV94wRJz9sP7 for ; Thu, 28 Oct 2021 15:53:05 +1100 (AEDT) Received: from localhost ([::1]:33442 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfxPT-0001kz-EB for incoming@patchwork.ozlabs.org; Thu, 28 Oct 2021 00:53:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50792) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxHB-00084K-94 for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:44:29 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:41722) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxH4-0002ce-Jy for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:44:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1635396262; x=1666932262; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NYpkni887wsvZV9VMS0VGs5wJ2vISIuVhBmrnIJ8b4U=; b=I/cMqDNU6s15AvLmGfsPlnzgKdGHCy6NFjud61iZG1LiOqrkkuuSa8SZ Umh5qE/aG9pI2brHmDw7BfDQnPkrxP53lobRrp3ScSfGapZgVrPcoE6tp e0DLn+a4LzRBkB67tXlFlYYGGigMSU7wP4bSuDYdzpT0ZdRfagmj6GkA/ lrwPeT0yBGEg+Y2ngf92WSGFj22FZL0xS5/xhNdDi7zOgU6otJhrpNWnX EFibxlR/D/QoFwrN5rehVf2ZWNOMvV789FYzfdvSQUJHfjUHYcYi2X0Qc TgOCiplqK7+DDu7uBWnipBQ+tw7wchUGz6mslcuj5uALliPoowzOG6stE Q==; X-IronPort-AV: E=Sophos;i="5.87,188,1631548800"; d="scan'208";a="184975499" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 28 Oct 2021 12:44:22 +0800 IronPort-SDR: b3mo7HKIJOJM5P1QPIvNWjNjqPKWPdcSO9MZ9ywHeyQXLp9JyORbtdJV+3M3Es+LFT5rmoYj2I VHyo5RYpxLz+X07pmSkv/RKCb83hN/lMD4a2L3SwFn7DeyH1pZRiJXpCub5KavbV9rno7qHR2k 80IG0+IYevYWG458lCwUCGQApGvd6zL2lTSyW8RaOYiavwexptVylHoajqcovJNN/b67YQJcFL uDfybApCa6p7A74cHVeLbKllmPzQLiGcbwQzAXAUyXVVv8f9Is/ApmU5kanr/wIr77Ka7gAizF Yqzwm82MFG4wwMHXkdtfDDtB Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:18:17 -0700 IronPort-SDR: DYUKaFYB4hiX4d5ee6crPNDMGrA6khsYrMiTcrSynNl/QWR9RKyr6OC7jK2K3YjFgxzf1nhS94 4JWaJt5dhxftnGdMFGPUHjkOUk+Qvsh8JSFXA6jd39wIInL5lPla6pcwSFj7hF8znEmQBC51tz 11vaS3ASs1wLHXpY4QtaA89+gF9P1W22M3JCRZJOzkLfyqI2cPJPui8CS196p/ICPjDzzpGAGC +qRkHr7u3+XonGbMbElW0Zq0GHoV9nHzRAaQdLxthDxc3rRKIi7SCTK6yr+Ndl1RM+Rv7ochE0 Jx4= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:44:22 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HftJ553sxz1RtVn for ; Wed, 27 Oct 2021 21:44:21 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1635396261; x=1637988262; bh=NYpkni887wsvZV9VMS 0VGs5wJ2vISIuVhBmrnIJ8b4U=; b=IJtbyPKYJFndEQhwrKB/C40uKlWCBWXjHL E5V3a/E3oY1lkdNYoRjGpKSluM9Oa1JmStdmt3wcwMUSoCGk07ShYPTVwWMUULJO m2iJl4Gwtw0VBTeoMcHQighMuhUMqg2F/CwnexDLa/8dZuux8pLo9h/nr6QfwGRY zmA2t/0xj6E9fJNw5Ve3zlcwK9oZeQhL7exstoZAh972DgKqpz96MIyw/ddCqkaa E4eyNR2q94lfR8bWlLEzOQHhWMafr3s1bDHDfp/qqKErXHyyYP37ZSHIG6xpAa6W vv+Re/bYN7+Bwts7L3tCOZI4mGRUx6KFQbmxHnRBoPJ6iLTY/MiQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id bYyQBgl3IC4s for ; Wed, 27 Oct 2021 21:44:21 -0700 (PDT) Received: from toolbox.alistair23.me (unknown [10.225.165.40]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HftJ224pQz1RtVl; Wed, 27 Oct 2021 21:44:17 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Alistair Francis , Bin Meng Subject: [PULL 06/18] hw/riscv: opentitan: Fixup the PLIC context addresses Date: Thu, 28 Oct 2021 14:43:30 +1000 Message-Id: <20211028044342.3070385-7-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> References: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=928ee31ee=alistair.francis@opensource.wdc.com; helo=esa6.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alistair Francis Fixup the PLIC context address to correctly support the threshold and claim register. Fixes: ef63100648 ("hw/riscv: opentitan: Update to the latest build") Signed-off-by: Alistair Francis Reviewed-by: Bin Meng Message-id: 20211025040657.262696-1-alistair.francis@opensource.wdc.com --- hw/riscv/opentitan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c index 83e1511f28..c531450b9f 100644 --- a/hw/riscv/opentitan.c +++ b/hw/riscv/opentitan.c @@ -161,8 +161,8 @@ static void lowrisc_ibex_soc_realize(DeviceState *dev_soc, Error **errp) qdev_prop_set_uint32(DEVICE(&s->plic), "pending-base", 0x1000); qdev_prop_set_uint32(DEVICE(&s->plic), "enable-base", 0x2000); qdev_prop_set_uint32(DEVICE(&s->plic), "enable-stride", 0x18); - qdev_prop_set_uint32(DEVICE(&s->plic), "context-base", 0x200004); - qdev_prop_set_uint32(DEVICE(&s->plic), "context-stride", 4); + qdev_prop_set_uint32(DEVICE(&s->plic), "context-base", 0x200000); + qdev_prop_set_uint32(DEVICE(&s->plic), "context-stride", 8); qdev_prop_set_uint32(DEVICE(&s->plic), "aperture-size", memmap[IBEX_DEV_PLIC].size); if (!sysbus_realize(SYS_BUS_DEVICE(&s->plic), errp)) { From patchwork Thu Oct 28 04:43:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1547319 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=T/D3Hhd7; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=Y5DQKH4p; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HftXn3QG2z9sP7 for ; Thu, 28 Oct 2021 15:55:21 +1100 (AEDT) Received: from localhost ([::1]:39090 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfxRf-0005ad-8g for incoming@patchwork.ozlabs.org; Thu, 28 Oct 2021 00:55:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50814) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxHG-0008D6-Fd for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:44:34 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:13343) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxHC-0004ka-80 for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:44:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1635396270; x=1666932270; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Jp9UVWaLwVNIzQpBAwcwf23Ysj/NKdZvzmtw/yFvBeM=; b=T/D3Hhd7NRUWoREROHNfGPOz9CzF/5vT7p/oY4Mv0om24dp2kvezga/C LvWHQSzio4903SzdEnrnOlPcSWYfyyTOMRaDHSIo9Xjrp01U11ZXtrZtQ DENkzJM87k4mltyZGdNHWMj6gBjfzvIgIs0HMC9XPIFvMcb8R8qvb+aYe /dGi3kvSBaTOG6a+t+jamXW2OoCqeVYZjfEzvkKnE9M9OfDKRvRHf5nDm DR8jqykFUB0UMXh9bvpJbgCd+qf497ep3pmMSIoMLSy0KGKUM7NNmUFkf x3tC5h2MpgpINlNSsGRpdCPwke6erkrn8rpBILVp2f9pJVIe2U1PIjrSU A==; X-IronPort-AV: E=Sophos;i="5.87,188,1631548800"; d="scan'208";a="287922951" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 28 Oct 2021 12:44:28 +0800 IronPort-SDR: EZGGwzxp6Cuwp8aExCS3nKiVVTP/VZwMrb9kiFpasJxunr7Fh0MKQYpVZUNsvLJ3ppaFLaHW5K 1Cyv3Vfbf2yCMDCoDllT/C/6vd+WPo4xduAZzkNMSM9phS5jElQMJa2UU8GSiVp6o0xU79/o5Z qSPTK8rRWxMgTZPVPGlMAWeZY5z+4YXKasNtJJDLkF1aR+Rt/5MZXtKXtMPvQKou9aFs38tfQ9 TRaZOWOJjmIfGHA2qrbZs6ZHomfgBGzO90tCPnXn6niUTnrjNwa3dw6HahT/pXWx18itYE3LTT dcQLyuDauhEpF9MOMJjuol+g Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:19:56 -0700 IronPort-SDR: 4NuxtVJfnPnzfNzK8E4YMPamtOuirduFqd1d/bJwfMNsuNhMiawC5Ngmf4DbsTKJTJ9mq6BKW1 mjsGFz0QAsKipo2PAbwB/HIxFQqhXsyCO4di3dlpRh/GM2Ac8byAwpR1KMwOsH10PxnUexX/Lu xgr/4ecaaG2qgAxD2Wfj7aPu4e2SXuUsSJkm89C0A1mLvyFmxTZl8IkGqJnEUptsn6/wMM39Ii hIFd9GNToNLD/8Rk9jYEvI95NJPOj/H265cMKJWUvH5DqdQY1OJ0Czz776dbvzEKocp1WXUpYf LMI= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:44:28 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HftJD137xz1RtVx for ; Wed, 27 Oct 2021 21:44:28 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1635396267; x=1637988268; bh=Jp9UVWaLwVNIzQpBAw cwf23Ysj/NKdZvzmtw/yFvBeM=; b=Y5DQKH4pfgvqzg+5rCD8i41pJFt+1CTTB/ Id9lIjSgCb1VJOxfQc73vb/lv1zf27VRMbhYr+AMJjFktQMC6SMowa0Rlb9upGvQ Ixr81PGatr+fhMdQc14XtCA8ZTJKHL52FKlUlxmqgfOCfCGyLlj35n3yV33xSUBU xcR3oyQglLC9qP/oUrDDEavT/0zPtAwaaMtHFB/x50DATdq2Vr7UA6bRwuUqYh2P AAKjCkSYmJKdnzS+cm0LJH6K48dKe3a4ncsyXBONTKq5f/2k0i6P/y3Uw6n53p0k upUhx9Prree5DnRk5Pvj+QZ85pnR9RlpAxAgdjQBgenkyYY66b+g== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id YLysdODVzFVF for ; Wed, 27 Oct 2021 21:44:27 -0700 (PDT) Received: from toolbox.alistair23.me (unknown [10.225.165.40]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HftJ64dkcz1RtVl; Wed, 27 Oct 2021 21:44:22 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Alexey Baturo , Alexey Baturo , Richard Henderson , Alistair Francis , Bin Meng Subject: [PULL 07/18] target/riscv: Add J-extension into RISC-V Date: Thu, 28 Oct 2021 14:43:31 +1000 Message-Id: <20211028044342.3070385-8-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> References: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=68.232.143.124; envelope-from=prvs=928ee31ee=alistair.francis@opensource.wdc.com; helo=esa2.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alexey Baturo Signed-off-by: Alexey Baturo Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis Reviewed-by: Bin Meng Message-id: 20211025173609.2724490-2-space.monkey.delivers@gmail.com Signed-off-by: Alistair Francis --- target/riscv/cpu.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index a33dc30be8..1cfc6a53a0 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -65,6 +65,7 @@ #define RVS RV('S') #define RVU RV('U') #define RVH RV('H') +#define RVJ RV('J') /* S extension denotes that Supervisor mode exists, however it is possible to have a core that support S mode but does not have an MMU and there @@ -291,6 +292,7 @@ struct RISCVCPU { bool ext_s; bool ext_u; bool ext_h; + bool ext_j; bool ext_v; bool ext_zba; bool ext_zbb; From patchwork Thu Oct 28 04:43:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1547321 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=P8X0WTQP; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=hUqw2tib; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hftbr652Cz9sS8 for ; Thu, 28 Oct 2021 15:58:00 +1100 (AEDT) Received: from localhost ([::1]:45128 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfxUE-0001Mf-MB for incoming@patchwork.ozlabs.org; Thu, 28 Oct 2021 00:57:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50866) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxHM-0008LS-O0 for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:44:42 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:13343) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxHI-0004ka-I4 for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:44:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1635396276; x=1666932276; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9TlHq+g1PTmL4wRl/eCa5PttqBFJeidVu8H54+9YNUs=; b=P8X0WTQP6rXUI3Q5Vuk8E/DHZY+fmEmfJZ8xcm1pLTLzQaFbylX5vfT2 qdSRwxfQt+Mq2g2V2ScmiXNQcX1cmt7EU+g3B+DmqRh+FyHhVYw8xznD5 NqQdn498c5z6Owi9vftIXfao+sW4CstRYP6SBUqy996BezLCjKtKM/RVp kI+mrrEyt92QfnXKOFpSBGNcGkpqqFO8ns58XWcs+Pvh4b7N5C/JrnyBP Tq8DiNHC8KZuKXyA69kVWv1E3oPvOXml6A8tLsD4zjTrv5I1X4cP5GcCP 8U7xPYXjQ7ddQDH63yeE+9jtHOY5G1zXruWp/maeZWidMEjzXq7Wmn4ga w==; X-IronPort-AV: E=Sophos;i="5.87,188,1631548800"; d="scan'208";a="287922953" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 28 Oct 2021 12:44:33 +0800 IronPort-SDR: L/XU8h4oxeKAXaRG+MIq/IyvFQDvRW/3yIOaIJwDmEMZpXgcsaJ6CUzdAkldsH3M2/M59QZnja hBGqF62S6jPdPFD2qozeHwCApVduh2fa22RmuSU/5nhes8zDv1Ik2cQy8TlPEegJHIUgWOBcqn wwO9m1zCCy1lhvaPSZ/oTAjp8LMlRVbL55cINYMT3SiIf/xENwKtA9Y67uBdGegdCbKNE9loPZ Qsf7dUGS71pOM7+o2Pg7/cMJdWIhabZt/lIYJGR8m2OC9hQLKygzn5pogL7GNbJBUdBTMx/KDA c5gMWPKh+28tViB8Bj+aLSEb Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:20:01 -0700 IronPort-SDR: 6kEglmztY8xpdBpw6fc93/dxuUZ3g1YlbpjzdXlVp9MrV0/XxvWTb+LwBrP99K/XIMEt2Q6x8Y CRyxjG6UyS5Guu6PLq5MYMOdvz3hHk3BJ8+63erEP+bjU19V8UqjHlL1MNcv6ASVWLSsCJgvqV AWmZVsKuUymapgpUIf5mkz2S15Jyev5xtkg113xwkpLyxjSP1ySReAhXJ8E/L3xcE4Mmrdg7yT dn2tdZi2t2aNSEepCJSq70hbaD/m1R7bPEI4VuaqdW5Jp37EA7vutjETNq493ZkJ1RFMz3yZzA /r0= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:44:33 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HftJK126Jz1RtVt for ; Wed, 27 Oct 2021 21:44:33 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1635396272; x=1637988273; bh=9TlHq+g1PTmL4wRl/e Ca5PttqBFJeidVu8H54+9YNUs=; b=hUqw2tibhHfrs8AuRZmjcarP2zjF5lRfc+ kDK8pq3sjrGY2ZNPxXO+5i6tWTSEAAtSjfKiein76ENesMbg8F4MSGHsIeRIcazI I5Uej0B2nEextjSDUBJEvly3r7CQhZndVl84zVts2ftAcSDvgGpc8AQ5X0Z4qgjI cZgaB/TwEJmOoEy0gnjG4M08e6R1j56lwb/lUv32wISLc3CgesAPQ9NQcZGQWFu8 wQBMRckVjvYYe6bmaDILzQP++VCDEwYXG/T6RlnhBY2h2mkGwX39aM0UJlm/ao6U wkHIRXYSl2BbtSVB6lVD382ZgAMBqtSj05RFHnHqpe4Jq6Vul6ZQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 06Wy8o-AhwxH for ; Wed, 27 Oct 2021 21:44:32 -0700 (PDT) Received: from toolbox.alistair23.me (unknown [10.225.165.40]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HftJD4WqYz1RtVl; Wed, 27 Oct 2021 21:44:28 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Alexey Baturo , Alexey Baturo , Alistair Francis Subject: [PULL 08/18] target/riscv: Add CSR defines for RISC-V PM extension Date: Thu, 28 Oct 2021 14:43:32 +1000 Message-Id: <20211028044342.3070385-9-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> References: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=68.232.143.124; envelope-from=prvs=928ee31ee=alistair.francis@opensource.wdc.com; helo=esa2.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alexey Baturo Signed-off-by: Alexey Baturo Reviewed-by: Alistair Francis Message-id: 20211025173609.2724490-3-space.monkey.delivers@gmail.com Signed-off-by: Alistair Francis --- target/riscv/cpu_bits.h | 96 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index cffcd3a5df..aa0bce4e06 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -334,6 +334,38 @@ #define CSR_MHPMCOUNTER30H 0xb9e #define CSR_MHPMCOUNTER31H 0xb9f +/* + * User PointerMasking registers + * NB: actual CSR numbers might be changed in future + */ +#define CSR_UMTE 0x4c0 +#define CSR_UPMMASK 0x4c1 +#define CSR_UPMBASE 0x4c2 + +/* + * Machine PointerMasking registers + * NB: actual CSR numbers might be changed in future + */ +#define CSR_MMTE 0x3c0 +#define CSR_MPMMASK 0x3c1 +#define CSR_MPMBASE 0x3c2 + +/* + * Supervisor PointerMaster registers + * NB: actual CSR numbers might be changed in future + */ +#define CSR_SMTE 0x1c0 +#define CSR_SPMMASK 0x1c1 +#define CSR_SPMBASE 0x1c2 + +/* + * Hypervisor PointerMaster registers + * NB: actual CSR numbers might be changed in future + */ +#define CSR_VSMTE 0x2c0 +#define CSR_VSPMMASK 0x2c1 +#define CSR_VSPMBASE 0x2c2 + /* mstatus CSR bits */ #define MSTATUS_UIE 0x00000001 #define MSTATUS_SIE 0x00000002 @@ -525,4 +557,68 @@ typedef enum RISCVException { #define MIE_UTIE (1 << IRQ_U_TIMER) #define MIE_SSIE (1 << IRQ_S_SOFT) #define MIE_USIE (1 << IRQ_U_SOFT) + +/* General PointerMasking CSR bits*/ +#define PM_ENABLE 0x00000001ULL +#define PM_CURRENT 0x00000002ULL +#define PM_INSN 0x00000004ULL +#define PM_XS_MASK 0x00000003ULL + +/* PointerMasking XS bits values */ +#define PM_EXT_DISABLE 0x00000000ULL +#define PM_EXT_INITIAL 0x00000001ULL +#define PM_EXT_CLEAN 0x00000002ULL +#define PM_EXT_DIRTY 0x00000003ULL + +/* Offsets for every pair of control bits per each priv level */ +#define XS_OFFSET 0ULL +#define U_OFFSET 2ULL +#define S_OFFSET 5ULL +#define M_OFFSET 8ULL + +#define PM_XS_BITS (PM_XS_MASK << XS_OFFSET) +#define U_PM_ENABLE (PM_ENABLE << U_OFFSET) +#define U_PM_CURRENT (PM_CURRENT << U_OFFSET) +#define U_PM_INSN (PM_INSN << U_OFFSET) +#define S_PM_ENABLE (PM_ENABLE << S_OFFSET) +#define S_PM_CURRENT (PM_CURRENT << S_OFFSET) +#define S_PM_INSN (PM_INSN << S_OFFSET) +#define M_PM_ENABLE (PM_ENABLE << M_OFFSET) +#define M_PM_CURRENT (PM_CURRENT << M_OFFSET) +#define M_PM_INSN (PM_INSN << M_OFFSET) + +/* mmte CSR bits */ +#define MMTE_PM_XS_BITS PM_XS_BITS +#define MMTE_U_PM_ENABLE U_PM_ENABLE +#define MMTE_U_PM_CURRENT U_PM_CURRENT +#define MMTE_U_PM_INSN U_PM_INSN +#define MMTE_S_PM_ENABLE S_PM_ENABLE +#define MMTE_S_PM_CURRENT S_PM_CURRENT +#define MMTE_S_PM_INSN S_PM_INSN +#define MMTE_M_PM_ENABLE M_PM_ENABLE +#define MMTE_M_PM_CURRENT M_PM_CURRENT +#define MMTE_M_PM_INSN M_PM_INSN +#define MMTE_MASK (MMTE_U_PM_ENABLE | MMTE_U_PM_CURRENT | MMTE_U_PM_INSN | \ + MMTE_S_PM_ENABLE | MMTE_S_PM_CURRENT | MMTE_S_PM_INSN | \ + MMTE_M_PM_ENABLE | MMTE_M_PM_CURRENT | MMTE_M_PM_INSN | \ + MMTE_PM_XS_BITS) + +/* (v)smte CSR bits */ +#define SMTE_PM_XS_BITS PM_XS_BITS +#define SMTE_U_PM_ENABLE U_PM_ENABLE +#define SMTE_U_PM_CURRENT U_PM_CURRENT +#define SMTE_U_PM_INSN U_PM_INSN +#define SMTE_S_PM_ENABLE S_PM_ENABLE +#define SMTE_S_PM_CURRENT S_PM_CURRENT +#define SMTE_S_PM_INSN S_PM_INSN +#define SMTE_MASK (SMTE_U_PM_ENABLE | SMTE_U_PM_CURRENT | SMTE_U_PM_INSN | \ + SMTE_S_PM_ENABLE | SMTE_S_PM_CURRENT | SMTE_S_PM_INSN | \ + SMTE_PM_XS_BITS) + +/* umte CSR bits */ +#define UMTE_U_PM_ENABLE U_PM_ENABLE +#define UMTE_U_PM_CURRENT U_PM_CURRENT +#define UMTE_U_PM_INSN U_PM_INSN +#define UMTE_MASK (UMTE_U_PM_ENABLE | MMTE_U_PM_CURRENT | UMTE_U_PM_INSN) + #endif From patchwork Thu Oct 28 04:43:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1547322 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=BhOfORDz; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=kazjgB8G; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HftdR3gS0z9sS8 for ; Thu, 28 Oct 2021 15:59:23 +1100 (AEDT) Received: from localhost ([::1]:47464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfxVZ-0002yb-BG for incoming@patchwork.ozlabs.org; Thu, 28 Oct 2021 00:59:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50888) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxHP-0008RC-N4 for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:44:43 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:41754) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxHM-000571-DM for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:44:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1635396280; x=1666932280; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ex8P5OZzdQADn82ihFvoY8GX9Xe4swqx4TgtYsQsBSU=; b=BhOfORDzS4lXfeiijdvGlu5EO0J9f1oLfE8iR1VAaaFeoijaOWzynmjK RnHLuvxQDSnJWcaEwhiKc6F9rm1stklf9iwrNr5Ku+f9ubbSZ0LhhmqbM k1hRhY3eG8p+V/PGDM/GNiltJglXS64Zqx9A4VJn/PUWFIdYcKW743YBv Hai6rpcd419+vR1bGKyH4wzQWQ2dbHjeLY1yhYW4BDvNBvf7Mahfp7MRT cpYDQTVBRdRqeL5qDf/0QVvE+cSHIkuQRmEIilrM0EGy3uKKj1CfNZEhX 49+UWIEvlwBsZKtKGiMlTdqXemO+5BA37DV0kOBAvQqhoy++7B2woBEwn A==; X-IronPort-AV: E=Sophos;i="5.87,188,1631548800"; d="scan'208";a="184975509" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 28 Oct 2021 12:44:39 +0800 IronPort-SDR: 6KavCrSaMqLVZILFfh6tU1ZTZ9qlaxMdghxuXkrjp8bbQz2UtEzPzJ8dCukxQkouKuMsYv7JLp zZAQLxQD3+VHhth+3I1a/evmbby6akB0rDYoncFr8p8aXEtOXDcnG4mHsOQmSfHwvy9WJIWTPX iSKdPLVQt3e11fmoF+7f0H5ouHiLmRX5NYgZdQMkIVdE8GvpB8WbnUFqaDbbKje43dXR2zT7uQ ikxnHA5gezs8QuNKbsKq4/D5jqVsvCAroZ5iWs9RW5Vv2WYxZKjm5Q4wB1wwazi6xvfi4fNNEM ggVZdUDyR6XdLPsZK5KB/0+A Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:18:33 -0700 IronPort-SDR: zMMIDxuDbUKbBQTy59hDp3ZsNHO11EtzQKT9cLPPHRQVfKYkJpKfMTtJbQFck3EFr3q7xinL2b dYNupEC0BLknvlWPgw3V1+Kv8Rlvrlz8rP2CQmMBVVsHhKyYWwTX6QE+zCbQVSIY4qd5u1gqwO 3XQaUf6CwpPOr8yon6aJzkSKUpez+NFa7smWA5zV3yk007u3IduaYqX8EzeGNy5E68ZGow3Eiu w2pyOKUPVkevp7X/KzpupcNtHbOhrfbbGxqaxQ4VkTUWxjTS6XWVY7yUxFjF93PnoQGYH/WzHb gaI= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:44:39 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HftJQ3LJyz1RtVv for ; Wed, 27 Oct 2021 21:44:38 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1635396277; x=1637988278; bh=ex8P5OZzdQADn82ihF voY8GX9Xe4swqx4TgtYsQsBSU=; b=kazjgB8GWlxehkF4iQJrvFBSeKVNYEdtuo XeFKC66g5J3I9q6Fk156haM52Fk01oMiuCq3ReNkN+YyALNXw/qnCP10+vW3pdlB hAypdH4PLMxX2QN0MH61q5KL2Y+CgIfv3V9unU3ooa3rxlvSMY8vkfKzV7yfksEv RdG8dMaJCa+pqUrDRhWotwfIgzTTBvtZwbeWYX9WHeuyXVMtoJP1XeRSdeLSolf6 aW83bQpKnZkoyh5YdcMMTosOIEzsWzcpATJ0CmFTuknt+tOEP5y0vsUZrwMCSV2g 8BjoFB4icEvO4x+FwmoMpdKHzLEhI2rP7dp7bG0L/FvmOtWt2NbQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 3fin86qletXa for ; Wed, 27 Oct 2021 21:44:37 -0700 (PDT) Received: from toolbox.alistair23.me (unknown [10.225.165.40]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HftJK3QY3z1RtVl; Wed, 27 Oct 2021 21:44:33 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Alexey Baturo , Alexey Baturo , Alistair Francis Subject: [PULL 09/18] target/riscv: Support CSRs required for RISC-V PM extension except for the h-mode Date: Thu, 28 Oct 2021 14:43:33 +1000 Message-Id: <20211028044342.3070385-10-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> References: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=928ee31ee=alistair.francis@opensource.wdc.com; helo=esa6.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alexey Baturo Signed-off-by: Alexey Baturo Reviewed-by: Alistair Francis Message-id: 20211025173609.2724490-4-space.monkey.delivers@gmail.com Signed-off-by: Alistair Francis --- target/riscv/cpu.h | 11 ++ target/riscv/cpu.c | 2 + target/riscv/csr.c | 285 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 298 insertions(+) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 1cfc6a53a0..b2422e3f99 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -238,6 +238,17 @@ struct CPURISCVState { /* True if in debugger mode. */ bool debugger; + + /* + * CSRs for PointerMasking extension + */ + target_ulong mmte; + target_ulong mpmmask; + target_ulong mpmbase; + target_ulong spmmask; + target_ulong spmbase; + target_ulong upmmask; + target_ulong upmbase; #endif float_status fp_status; diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 788fa0b11c..6b767a4a0b 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -367,6 +367,8 @@ static void riscv_cpu_reset(DeviceState *dev) env->mcause = 0; env->pc = env->resetvec; env->two_stage_lookup = false; + /* mmte is supposed to have pm.current hardwired to 1 */ + env->mmte |= (PM_EXT_INITIAL | MMTE_M_PM_CURRENT); #endif cs->exception_index = RISCV_EXCP_NONE; env->load_res = -1; diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 69e4d65fcd..9f41954894 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -192,6 +192,16 @@ static RISCVException hmode32(CPURISCVState *env, int csrno) } +/* Checks if PointerMasking registers could be accessed */ +static RISCVException pointer_masking(CPURISCVState *env, int csrno) +{ + /* Check if j-ext is present */ + if (riscv_has_ext(env, RVJ)) { + return RISCV_EXCP_NONE; + } + return RISCV_EXCP_ILLEGAL_INST; +} + static RISCVException pmp(CPURISCVState *env, int csrno) { if (riscv_feature(env, RISCV_FEATURE_PMP)) { @@ -1425,6 +1435,268 @@ static RISCVException write_pmpaddr(CPURISCVState *env, int csrno, return RISCV_EXCP_NONE; } +/* + * Functions to access Pointer Masking feature registers + * We have to check if current priv lvl could modify + * csr in given mode + */ +static bool check_pm_current_disabled(CPURISCVState *env, int csrno) +{ + int csr_priv = get_field(csrno, 0x300); + int pm_current; + + /* + * If priv lvls differ that means we're accessing csr from higher priv lvl, + * so allow the access + */ + if (env->priv != csr_priv) { + return false; + } + switch (env->priv) { + case PRV_M: + pm_current = get_field(env->mmte, M_PM_CURRENT); + break; + case PRV_S: + pm_current = get_field(env->mmte, S_PM_CURRENT); + break; + case PRV_U: + pm_current = get_field(env->mmte, U_PM_CURRENT); + break; + default: + g_assert_not_reached(); + } + /* It's same priv lvl, so we allow to modify csr only if pm.current==1 */ + return !pm_current; +} + +static RISCVException read_mmte(CPURISCVState *env, int csrno, + target_ulong *val) +{ + *val = env->mmte & MMTE_MASK; + return RISCV_EXCP_NONE; +} + +static RISCVException write_mmte(CPURISCVState *env, int csrno, + target_ulong val) +{ + uint64_t mstatus; + target_ulong wpri_val = val & MMTE_MASK; + + if (val != wpri_val) { + qemu_log_mask(LOG_GUEST_ERROR, "%s" TARGET_FMT_lx " %s" TARGET_FMT_lx "\n", + "MMTE: WPRI violation written 0x", val, + "vs expected 0x", wpri_val); + } + /* for machine mode pm.current is hardwired to 1 */ + wpri_val |= MMTE_M_PM_CURRENT; + + /* hardwiring pm.instruction bit to 0, since it's not supported yet */ + wpri_val &= ~(MMTE_M_PM_INSN | MMTE_S_PM_INSN | MMTE_U_PM_INSN); + env->mmte = wpri_val | PM_EXT_DIRTY; + + /* Set XS and SD bits, since PM CSRs are dirty */ + mstatus = env->mstatus | MSTATUS_XS; + write_mstatus(env, csrno, mstatus); + return RISCV_EXCP_NONE; +} + +static RISCVException read_smte(CPURISCVState *env, int csrno, + target_ulong *val) +{ + *val = env->mmte & SMTE_MASK; + return RISCV_EXCP_NONE; +} + +static RISCVException write_smte(CPURISCVState *env, int csrno, + target_ulong val) +{ + target_ulong wpri_val = val & SMTE_MASK; + + if (val != wpri_val) { + qemu_log_mask(LOG_GUEST_ERROR, "%s" TARGET_FMT_lx " %s" TARGET_FMT_lx "\n", + "SMTE: WPRI violation written 0x", val, + "vs expected 0x", wpri_val); + } + + /* if pm.current==0 we can't modify current PM CSRs */ + if (check_pm_current_disabled(env, csrno)) { + return RISCV_EXCP_NONE; + } + + wpri_val |= (env->mmte & ~SMTE_MASK); + write_mmte(env, csrno, wpri_val); + return RISCV_EXCP_NONE; +} + +static RISCVException read_umte(CPURISCVState *env, int csrno, + target_ulong *val) +{ + *val = env->mmte & UMTE_MASK; + return RISCV_EXCP_NONE; +} + +static RISCVException write_umte(CPURISCVState *env, int csrno, + target_ulong val) +{ + target_ulong wpri_val = val & UMTE_MASK; + + if (val != wpri_val) { + qemu_log_mask(LOG_GUEST_ERROR, "%s" TARGET_FMT_lx " %s" TARGET_FMT_lx "\n", + "UMTE: WPRI violation written 0x", val, + "vs expected 0x", wpri_val); + } + + if (check_pm_current_disabled(env, csrno)) { + return RISCV_EXCP_NONE; + } + + wpri_val |= (env->mmte & ~UMTE_MASK); + write_mmte(env, csrno, wpri_val); + return RISCV_EXCP_NONE; +} + +static RISCVException read_mpmmask(CPURISCVState *env, int csrno, + target_ulong *val) +{ + *val = env->mpmmask; + return RISCV_EXCP_NONE; +} + +static RISCVException write_mpmmask(CPURISCVState *env, int csrno, + target_ulong val) +{ + uint64_t mstatus; + + env->mpmmask = val; + env->mmte |= PM_EXT_DIRTY; + + /* Set XS and SD bits, since PM CSRs are dirty */ + mstatus = env->mstatus | MSTATUS_XS; + write_mstatus(env, csrno, mstatus); + return RISCV_EXCP_NONE; +} + +static RISCVException read_spmmask(CPURISCVState *env, int csrno, + target_ulong *val) +{ + *val = env->spmmask; + return RISCV_EXCP_NONE; +} + +static RISCVException write_spmmask(CPURISCVState *env, int csrno, + target_ulong val) +{ + uint64_t mstatus; + + /* if pm.current==0 we can't modify current PM CSRs */ + if (check_pm_current_disabled(env, csrno)) { + return RISCV_EXCP_NONE; + } + env->spmmask = val; + env->mmte |= PM_EXT_DIRTY; + + /* Set XS and SD bits, since PM CSRs are dirty */ + mstatus = env->mstatus | MSTATUS_XS; + write_mstatus(env, csrno, mstatus); + return RISCV_EXCP_NONE; +} + +static RISCVException read_upmmask(CPURISCVState *env, int csrno, + target_ulong *val) +{ + *val = env->upmmask; + return RISCV_EXCP_NONE; +} + +static RISCVException write_upmmask(CPURISCVState *env, int csrno, + target_ulong val) +{ + uint64_t mstatus; + + /* if pm.current==0 we can't modify current PM CSRs */ + if (check_pm_current_disabled(env, csrno)) { + return RISCV_EXCP_NONE; + } + env->upmmask = val; + env->mmte |= PM_EXT_DIRTY; + + /* Set XS and SD bits, since PM CSRs are dirty */ + mstatus = env->mstatus | MSTATUS_XS; + write_mstatus(env, csrno, mstatus); + return RISCV_EXCP_NONE; +} + +static RISCVException read_mpmbase(CPURISCVState *env, int csrno, + target_ulong *val) +{ + *val = env->mpmbase; + return RISCV_EXCP_NONE; +} + +static RISCVException write_mpmbase(CPURISCVState *env, int csrno, + target_ulong val) +{ + uint64_t mstatus; + + env->mpmbase = val; + env->mmte |= PM_EXT_DIRTY; + + /* Set XS and SD bits, since PM CSRs are dirty */ + mstatus = env->mstatus | MSTATUS_XS; + write_mstatus(env, csrno, mstatus); + return RISCV_EXCP_NONE; +} + +static RISCVException read_spmbase(CPURISCVState *env, int csrno, + target_ulong *val) +{ + *val = env->spmbase; + return RISCV_EXCP_NONE; +} + +static RISCVException write_spmbase(CPURISCVState *env, int csrno, + target_ulong val) +{ + uint64_t mstatus; + + /* if pm.current==0 we can't modify current PM CSRs */ + if (check_pm_current_disabled(env, csrno)) { + return RISCV_EXCP_NONE; + } + env->spmbase = val; + env->mmte |= PM_EXT_DIRTY; + + /* Set XS and SD bits, since PM CSRs are dirty */ + mstatus = env->mstatus | MSTATUS_XS; + write_mstatus(env, csrno, mstatus); + return RISCV_EXCP_NONE; +} + +static RISCVException read_upmbase(CPURISCVState *env, int csrno, + target_ulong *val) +{ + *val = env->upmbase; + return RISCV_EXCP_NONE; +} + +static RISCVException write_upmbase(CPURISCVState *env, int csrno, + target_ulong val) +{ + uint64_t mstatus; + + /* if pm.current==0 we can't modify current PM CSRs */ + if (check_pm_current_disabled(env, csrno)) { + return RISCV_EXCP_NONE; + } + env->upmbase = val; + env->mmte |= PM_EXT_DIRTY; + + /* Set XS and SD bits, since PM CSRs are dirty */ + mstatus = env->mstatus | MSTATUS_XS; + write_mstatus(env, csrno, mstatus); + return RISCV_EXCP_NONE; +} + #endif /* @@ -1659,6 +1931,19 @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] = { [CSR_PMPADDR14] = { "pmpaddr14", pmp, read_pmpaddr, write_pmpaddr }, [CSR_PMPADDR15] = { "pmpaddr15", pmp, read_pmpaddr, write_pmpaddr }, + /* User Pointer Masking */ + [CSR_UMTE] = { "umte", pointer_masking, read_umte, write_umte }, + [CSR_UPMMASK] = { "upmmask", pointer_masking, read_upmmask, write_upmmask }, + [CSR_UPMBASE] = { "upmbase", pointer_masking, read_upmbase, write_upmbase }, + /* Machine Pointer Masking */ + [CSR_MMTE] = { "mmte", pointer_masking, read_mmte, write_mmte }, + [CSR_MPMMASK] = { "mpmmask", pointer_masking, read_mpmmask, write_mpmmask }, + [CSR_MPMBASE] = { "mpmbase", pointer_masking, read_mpmbase, write_mpmbase }, + /* Supervisor Pointer Masking */ + [CSR_SMTE] = { "smte", pointer_masking, read_smte, write_smte }, + [CSR_SPMMASK] = { "spmmask", pointer_masking, read_spmmask, write_spmmask }, + [CSR_SPMBASE] = { "spmbase", pointer_masking, read_spmbase, write_spmbase }, + /* Performance Counters */ [CSR_HPMCOUNTER3] = { "hpmcounter3", ctr, read_zero }, [CSR_HPMCOUNTER4] = { "hpmcounter4", ctr, read_zero }, From patchwork Thu Oct 28 04:43:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1547323 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=XriSxVOE; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=Y1tHLC8u; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HftgS5sK1z9sS8 for ; Thu, 28 Oct 2021 16:01:08 +1100 (AEDT) Received: from localhost ([::1]:49684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfxXG-0004Uj-Jy for incoming@patchwork.ozlabs.org; Thu, 28 Oct 2021 01:01:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50920) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxHV-0000If-EA for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:44:49 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:41761) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxHP-00057N-Sy for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:44:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1635396285; x=1666932285; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NOi2wUJPbzMYjoO8hDlZIw3xVQn+T7NEBBLu6imMlYQ=; b=XriSxVOETW3d2BHxbKvc01x5BjzsRV9pMxu7NrQp9+2uek5pIRQeCGPy DwDtwtiyOp1fVZd9Tarsrmwsr6PByZM/PPTykboq0VuNxsHRscPI3s89N 31mEbsdZ+mc+TlB6GUi5XZsrXmfDaueB3C+t1r97J3Fs1UnrWih53+fQs +RAkMMqIfCJGjf5FnsoVWOeOy5+EgLoqH88NnYf+O30b9FsWq4weDa2Sr bJ9K8vFMGsJWayyz3nBkHiXqs86Yre7pag3wuDXVifaKBeCYtLXo1o+7s S2lISwhLu5hMuTrkNBhw19e924WW08gNah3u18OSHtrfeT3yAihot0I99 Q==; X-IronPort-AV: E=Sophos;i="5.87,188,1631548800"; d="scan'208";a="184975511" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 28 Oct 2021 12:44:44 +0800 IronPort-SDR: +O90PoQN/lb0UGU0bj7YaFKxjjNtMDp9QnPUxA01G9AKQSrYDN+Hqbm0RZUeyPCvbYmRC6dw7J sxRBK+yaG8TYOzO6PTHGDasLa5sIkEWiK02euH4vgz52ueX9jDfDMVTJadIIIi72lyVFo7GCHg WWJxADxspXakjAOUPh6amkT6II3n80lACUlClULdO/uJPJGsH+wUk/H+RXIqJTDvOnY79I3SRv 7kHqYQLT4ENkTJ9O/He8AchYK9dw5u5V6Mgrs1zIhwg6EHpbNkTPemY/+wn253KQgWlarCfG+l P4AywtEbHw7N26h9Wikd/kA3 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:18:37 -0700 IronPort-SDR: Wm2JUIJTC7V08xIMu4EsUJM/d4mq/DxlDwUEbHvtkAqhSo6SsdMdK6PgowFSjcgbwuonMwG/7R Pnf5vCfvqXOPZ2JZjym+0Ofvz02PzR7aDUBHXJ4oSAH8BZ6pDPsQuvUMacWDt1aVylmMWy8Y8l +LzgcgMLKcYZnmjTrL5ysi8jBalh4S3HR/QFy58PotVh41CGpmSpybXPB6iF8sq1K56A72IP8C JT3WFJkcMRrfh2dRq7JGKdvg4jWwMLCGk7F3QCVpc9ZWF0gHNC0mDJAreRdjfOBH3iG9vfZ5t8 WdU= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:44:42 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HftJV2nSrz1RtVm for ; Wed, 27 Oct 2021 21:44:42 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1635396282; x=1637988283; bh=NOi2wUJPbzMYjoO8hD lZIw3xVQn+T7NEBBLu6imMlYQ=; b=Y1tHLC8uFevzTmVyAcDV6tl0IwPzCPZsoM p288AugJXwgwrR8QBcfUDZ7uW4krfoiupjvv7aATLIWVDIeP2aohvF4jCWdMJ5dF EpbsCjHd59HD+q9O06u06h4tk1kSbUQq55FlSsdw0xWT04QHzFPeIB60EnTD/XFR rvYpaL9jEX4+xZ62n/4b9eFxv9HT/NnfQ1v/Tm60x+xC+CnO6MDP7iV9eQ3tborb GjnJxfaOiOuu2vgP1NJvIUUGpcesipoJc53607e8vToe3ShkGEaEhL10mqoBK6Fb /sn1gC+nNlT3uiJVmG4OC3J5ssyb5g50jt7EQcDedMTq7iuHoHaA== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id w151jX12ZttT for ; Wed, 27 Oct 2021 21:44:42 -0700 (PDT) Received: from toolbox.alistair23.me (unknown [10.225.165.40]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HftJQ3ZNMz1RtVw; Wed, 27 Oct 2021 21:44:38 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Alexey Baturo , Alexey Baturo , Alistair Francis Subject: [PULL 10/18] target/riscv: Add J extension state description Date: Thu, 28 Oct 2021 14:43:34 +1000 Message-Id: <20211028044342.3070385-11-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> References: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=928ee31ee=alistair.francis@opensource.wdc.com; helo=esa6.hgst.iphmx.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alexey Baturo Signed-off-by: Alexey Baturo Reviewed-by: Alistair Francis Message-id: 20211025173609.2724490-5-space.monkey.delivers@gmail.com Signed-off-by: Alistair Francis --- target/riscv/machine.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/target/riscv/machine.c b/target/riscv/machine.c index f64b2a96c1..7b4c739564 100644 --- a/target/riscv/machine.c +++ b/target/riscv/machine.c @@ -84,6 +84,14 @@ static bool vector_needed(void *opaque) return riscv_has_ext(env, RVV); } +static bool pointermasking_needed(void *opaque) +{ + RISCVCPU *cpu = opaque; + CPURISCVState *env = &cpu->env; + + return riscv_has_ext(env, RVJ); +} + static const VMStateDescription vmstate_vector = { .name = "cpu/vector", .version_id = 1, @@ -100,6 +108,24 @@ static const VMStateDescription vmstate_vector = { } }; +static const VMStateDescription vmstate_pointermasking = { + .name = "cpu/pointer_masking", + .version_id = 1, + .minimum_version_id = 1, + .needed = pointermasking_needed, + .fields = (VMStateField[]) { + VMSTATE_UINTTL(env.mmte, RISCVCPU), + VMSTATE_UINTTL(env.mpmmask, RISCVCPU), + VMSTATE_UINTTL(env.mpmbase, RISCVCPU), + VMSTATE_UINTTL(env.spmmask, RISCVCPU), + VMSTATE_UINTTL(env.spmbase, RISCVCPU), + VMSTATE_UINTTL(env.upmmask, RISCVCPU), + VMSTATE_UINTTL(env.upmbase, RISCVCPU), + + VMSTATE_END_OF_LIST() + } +}; + static const VMStateDescription vmstate_hyper = { .name = "cpu/hyper", .version_id = 1, @@ -191,6 +217,7 @@ const VMStateDescription vmstate_riscv_cpu = { &vmstate_pmp, &vmstate_hyper, &vmstate_vector, + &vmstate_pointermasking, NULL } }; From patchwork Thu Oct 28 04:43:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1547312 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=RgbpHw00; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=MQIsXmqK; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HftMm75Q5z9sP7 for ; Thu, 28 Oct 2021 15:47:32 +1100 (AEDT) Received: from localhost ([::1]:49712 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfxK6-0001U4-KU for incoming@patchwork.ozlabs.org; Thu, 28 Oct 2021 00:47:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50928) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxHW-0000LA-8l for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:44:50 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:41754) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxHU-000571-5J for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:44:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1635396289; x=1666932289; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uXZMUuGz8PVeGA7k0v699hnnvPnR8BIPKrSp1FBz7Ms=; b=RgbpHw00Jb7Umo7QgXpZsSZT2dYJVF65qZNLFeHwM0UxDhu108C7yQ5h 75Esp1DmaEXAHHttPJrSfjEzBYlDvA2pW10YQirgTtcAjVtKhTdjnCldZ 5eFNd9pKhgiu0SFrpdzdeKaVpZHAJcEsuSHZ6qLkXcIKibuq6uZot4lm3 rVxzUdZuf2V3SSy1R0+q/YHlvhPU/gYnjZTgdjr6u3ZKRdO1TBK9UPf2n gATQb0HShn94AOsi2Br5vcVnRw/whDdsgHsqjrr+BhqABl/D2B7cd0bEE oWHolrIOtkkT563X7GXEsjYaBXy4eSmjbkVwl3n2nn/u09XM+gF1xUFc9 Q==; X-IronPort-AV: E=Sophos;i="5.87,188,1631548800"; d="scan'208";a="184975515" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 28 Oct 2021 12:44:48 +0800 IronPort-SDR: OZO5tfHhMf5vWsHW+ATHIo1Y6PoIK4msAKhJvvucWRc1c+ZMuTWIs01PT1rFKyTcJI5YQloP// t83Pir//9OYhRIIemhpdCw3l28G2nqubCA6HW1VFKAkKg4VGfUOwIoDQrHEbaoqDoK0dMFy7XF fYBnXbMm11osEbhjd+lNrsywBR+WfJKESpUuPlgXyfIjwS/eI/etsBfObdsMgra5I3Rk76vPHT c8/8H3qEom52KW5Z1RfMXMnDcPTw5MVctjGmfd0n6stpgrXEJLvOpUkenvLIA9K7+5b3DfzBzM ir/qqDihIWrX8FGhq9qbL3lN Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:18:42 -0700 IronPort-SDR: 5L39mFlt9zkimg6gCbvHWe9y2Y3sfHAeNSu8xmeOU4sl6cK2hV5rvWtBmpLOoz7f2AtpfZUaXf WLTHQdXSTLuRvenWjH2ZGQf1lMHPH2TGo0RIQscYzckYhZJe5QTFHa7Zl0zSY2ssyGLXHs054b ctIWfyYrxlEulb7nXShyHTWghNalDqKmGHycrYwCtZT0WSZH357sflCfWWG495Pl6hKDYkZrTF RJIRPaMYny3sawjA6AUCXG22Jz3U+V+oEukNB8osaFuECRaHLHPsLRFeDinHjsqI+9oRTEACz/ QN4= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:44:47 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HftJb1bnVz1RtVv for ; Wed, 27 Oct 2021 21:44:47 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1635396286; x=1637988287; bh=uXZMUuGz8PVeGA7k0v 699hnnvPnR8BIPKrSp1FBz7Ms=; b=MQIsXmqKvtIP7QAoKb7Ev9yXzCo3AXrERn Oqg81wiNHRkXppgOjic+oLfi3bKypZjqQnFZPIkrXHI26W4UR/5gwOXDKJXb1Avd SgkfMnrLX22x7LhEr7HG+1C0BQhyCEj6RsuRjNbDmWm3nD4O1g9MbacL/1pJVhjf TVdSJaezVUHxTmvPMkNPaXPISsBp4n87skKzyr7AQzuPgAb0/veahdkjphqMb3GI NuD4VEXL9tjKAy3Jdm/hPELBQZcmHFOwdgkdBBCuOvtIMSazzqZcR+dU1bpxkGdX RiZbwMc7N735irc7JPpfcXVPHwdC5vWHhp5NL1ftTvCborS4pOOA== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 3ARg8lRKKfbM for ; Wed, 27 Oct 2021 21:44:46 -0700 (PDT) Received: from toolbox.alistair23.me (unknown [10.225.165.40]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HftJW0vXdz1RtVl; Wed, 27 Oct 2021 21:44:42 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Alexey Baturo , Alexey Baturo , Alistair Francis Subject: [PULL 11/18] target/riscv: Print new PM CSRs in QEMU logs Date: Thu, 28 Oct 2021 14:43:35 +1000 Message-Id: <20211028044342.3070385-12-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> References: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.45; envelope-from=prvs=928ee31ee=alistair.francis@opensource.wdc.com; helo=esa6.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alexey Baturo Signed-off-by: Alexey Baturo Reviewed-by: Alistair Francis Message-id: 20211025173609.2724490-6-space.monkey.delivers@gmail.com Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 6b767a4a0b..16fac64806 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -271,6 +271,13 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags) CSR_MSCRATCH, CSR_SSCRATCH, CSR_SATP, + CSR_MMTE, + CSR_UPMBASE, + CSR_UPMMASK, + CSR_SPMBASE, + CSR_SPMMASK, + CSR_MPMBASE, + CSR_MPMMASK, }; for (int i = 0; i < ARRAY_SIZE(dump_csrs); ++i) { From patchwork Thu Oct 28 04:43:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1547315 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=aW8jZQNg; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=sbyC3PJn; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HftRp44S3z9sP7 for ; Thu, 28 Oct 2021 15:51:01 +1100 (AEDT) Received: from localhost ([::1]:57448 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfxNR-0007CV-Of for incoming@patchwork.ozlabs.org; Thu, 28 Oct 2021 00:50:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxHc-0000VL-Rr for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:44:57 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:13374) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxHa-00059i-BV for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:44:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1635396294; x=1666932294; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/o5ylGtDG9WEJprAVtcrrZ+GBejGN7Ll5LX1ADFWUZs=; b=aW8jZQNgeBCHlmUKRyCRx4+73PhKours5uYzEwiHH9C+XmkULYRohzyb xaPOu1HUCXfGkQh8NqeBPx3XxaqlYPkIrZ8/Gfr0/tokQyuo4kWqSGF/O bS8B2OGpWq5QNNEdDZSvQeMIFeZroPRnCfGSurO+pcwTnUXtULEVj2wHr bveLdoMndV2PbsfwNQiiZGjviCcFzt+hRNLB5oCcb02wghlWul7K7i9si O2Cb6o+t5ZQTR4Lm4aBtvpXKYhmwEFWgxSKWwTzcCG7yQ3QWS25RzUr51 gEOZKB+rQlz3r9SJjDQO/MFinCrhn2ndIIyYzlMxk205KgAxuTMvMEquI w==; X-IronPort-AV: E=Sophos;i="5.87,188,1631548800"; d="scan'208";a="287922974" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 28 Oct 2021 12:44:53 +0800 IronPort-SDR: 60R7yawGt3pOWuM7KZ7+a3RDVYb7ZeJrHYgjhkCvmeVNkPnaOGrVgEBn4fKDGZ3YDkYZz3wrX7 5BN8kYkvESMHh5LB0FDSRJl6+hNwi2qQ1ERlIjdHum+UYpL9IoePwCpIr8lwoF0RvXS1EObU95 uc00MCMWxya1PTHuHZA8FWmZ0YRSNAezJA+la5nl8EFPvwnyawNuE9OZVqeoLk95T1hHxlGC+a DBUDE8A3tAne5ULpvVXxF2Qpcu6VXoVL+871WVmy/ezlX0UlaCMJIBq3rNi/uhHfzoi8Rjz9LD O1vjSKkJ74EfPZecBvLTzz7u Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:18:48 -0700 IronPort-SDR: N0of5BTjqf/IahpH7BiiHCdYwvwbV+6NDtMmK6MNbIuSgy47DFSZ1GFZpfNhJUOUSyyc4UVyLk s9SpZ0fijGQqLXIsnqe5g5MD677hIDyuewftAD8iUbwvt3LWShk78hqUtK71ubLVJnl8mJQTFv fhKBvp+24W4oWZDqOTunKwwU3kzE5s/QyGpd/GL2zAQ2DlUhgU8EYyfY+lNAUbQNK1VBvGtNlt ut3B4nxBQgRdq6FkROvqBoTYYyqIkI0AWpcYP7ZroaOBqGM8ltxrwtIWJ0yLfKYNxzkArEh3/V Njs= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:44:53 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HftJh5mgSz1RtVp for ; Wed, 27 Oct 2021 21:44:52 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1635396292; x=1637988293; bh=/o5ylGtDG9WEJprAVt crrZ+GBejGN7Ll5LX1ADFWUZs=; b=sbyC3PJne5uOkuXKUbi1JzCdTysQlja28r kD/uCECZOEqMDKQI8XHCfORPofLf8utlSaICDc31n03KLaa8oBL9tKcbgRQ1nNJZ lNxldchgwLsqX8fBkETLs4LoXgCs3ge6i6Z3cpIokcKAVNX69tfnW3Ooi+5aJwGE oaV1pgUR4NwTb8tHFvufTJFuud3xRhgpOKivCvXQVAJ8hv9W1sU4ErAVZicNh72E VX9ZPX86lCLd99pcLM5LHJkr7HrXNJhuSJ2vOLmCOMsLzM8UpVyiHsHNe/BXuDiX kg9Yz8XDGFSkbXs5gvyBB6OhS06/uWI+xJ+qpDxKZInYAhbCwwBg== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id HGTIILxtSBK1 for ; Wed, 27 Oct 2021 21:44:52 -0700 (PDT) Received: from toolbox.alistair23.me (unknown [10.225.165.40]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HftJb6BVmz1RtVl; Wed, 27 Oct 2021 21:44:47 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Alexey Baturo , Alexey Baturo , Richard Henderson , Alistair Francis Subject: [PULL 12/18] target/riscv: Support pointer masking for RISC-V for i/c/f/d/a types of instructions Date: Thu, 28 Oct 2021 14:43:36 +1000 Message-Id: <20211028044342.3070385-13-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> References: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=68.232.143.124; envelope-from=prvs=928ee31ee=alistair.francis@opensource.wdc.com; helo=esa2.hgst.iphmx.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, GAPPY_SUBJECT=0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alexey Baturo Signed-off-by: Alexey Baturo Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis Message-id: 20211025173609.2724490-7-space.monkey.delivers@gmail.com Signed-off-by: Alistair Francis --- target/riscv/translate.c | 8 ++++++++ target/riscv/insn_trans/trans_rva.c.inc | 3 +++ target/riscv/insn_trans/trans_rvd.c.inc | 2 ++ target/riscv/insn_trans/trans_rvf.c.inc | 2 ++ target/riscv/insn_trans/trans_rvi.c.inc | 2 ++ 5 files changed, 17 insertions(+) diff --git a/target/riscv/translate.c b/target/riscv/translate.c index d38f87d718..a5e6fa145d 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -271,6 +271,14 @@ static void gen_jal(DisasContext *ctx, int rd, target_ulong imm) ctx->base.is_jmp = DISAS_NORETURN; } +/* + * Temp stub: generates address adjustment for PointerMasking + */ +static TCGv gen_pm_adjust_address(DisasContext *s, TCGv src) +{ + return src; +} + #ifndef CONFIG_USER_ONLY /* The states of mstatus_fs are: * 0 = disabled, 1 = initial, 2 = clean, 3 = dirty diff --git a/target/riscv/insn_trans/trans_rva.c.inc b/target/riscv/insn_trans/trans_rva.c.inc index 6ea07d89b0..40fe132b04 100644 --- a/target/riscv/insn_trans/trans_rva.c.inc +++ b/target/riscv/insn_trans/trans_rva.c.inc @@ -25,6 +25,7 @@ static bool gen_lr(DisasContext *ctx, arg_atomic *a, MemOp mop) if (a->rl) { tcg_gen_mb(TCG_MO_ALL | TCG_BAR_STRL); } + src1 = gen_pm_adjust_address(ctx, src1); tcg_gen_qemu_ld_tl(load_val, src1, ctx->mem_idx, mop); if (a->aq) { tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ); @@ -44,6 +45,7 @@ static bool gen_sc(DisasContext *ctx, arg_atomic *a, MemOp mop) TCGLabel *l2 = gen_new_label(); src1 = get_gpr(ctx, a->rs1, EXT_ZERO); + src1 = gen_pm_adjust_address(ctx, src1); tcg_gen_brcond_tl(TCG_COND_NE, load_res, src1, l1); /* @@ -84,6 +86,7 @@ static bool gen_amo(DisasContext *ctx, arg_atomic *a, TCGv src1 = get_gpr(ctx, a->rs1, EXT_NONE); TCGv src2 = get_gpr(ctx, a->rs2, EXT_NONE); + src1 = gen_pm_adjust_address(ctx, src1); func(dest, src1, src2, ctx->mem_idx, mop); gen_set_gpr(ctx, a->rd, dest); diff --git a/target/riscv/insn_trans/trans_rvd.c.inc b/target/riscv/insn_trans/trans_rvd.c.inc index db9ae15755..64fb0046f7 100644 --- a/target/riscv/insn_trans/trans_rvd.c.inc +++ b/target/riscv/insn_trans/trans_rvd.c.inc @@ -31,6 +31,7 @@ static bool trans_fld(DisasContext *ctx, arg_fld *a) tcg_gen_addi_tl(temp, addr, a->imm); addr = temp; } + addr = gen_pm_adjust_address(ctx, addr); tcg_gen_qemu_ld_i64(cpu_fpr[a->rd], addr, ctx->mem_idx, MO_TEQ); @@ -51,6 +52,7 @@ static bool trans_fsd(DisasContext *ctx, arg_fsd *a) tcg_gen_addi_tl(temp, addr, a->imm); addr = temp; } + addr = gen_pm_adjust_address(ctx, addr); tcg_gen_qemu_st_i64(cpu_fpr[a->rs2], addr, ctx->mem_idx, MO_TEQ); diff --git a/target/riscv/insn_trans/trans_rvf.c.inc b/target/riscv/insn_trans/trans_rvf.c.inc index bddbd418d9..b5459249c4 100644 --- a/target/riscv/insn_trans/trans_rvf.c.inc +++ b/target/riscv/insn_trans/trans_rvf.c.inc @@ -37,6 +37,7 @@ static bool trans_flw(DisasContext *ctx, arg_flw *a) tcg_gen_addi_tl(temp, addr, a->imm); addr = temp; } + addr = gen_pm_adjust_address(ctx, addr); dest = cpu_fpr[a->rd]; tcg_gen_qemu_ld_i64(dest, addr, ctx->mem_idx, MO_TEUL); @@ -59,6 +60,7 @@ static bool trans_fsw(DisasContext *ctx, arg_fsw *a) tcg_gen_addi_tl(temp, addr, a->imm); addr = temp; } + addr = gen_pm_adjust_address(ctx, addr); tcg_gen_qemu_st_i64(cpu_fpr[a->rs2], addr, ctx->mem_idx, MO_TEUL); diff --git a/target/riscv/insn_trans/trans_rvi.c.inc b/target/riscv/insn_trans/trans_rvi.c.inc index 91dc438a3a..e51dbc41c5 100644 --- a/target/riscv/insn_trans/trans_rvi.c.inc +++ b/target/riscv/insn_trans/trans_rvi.c.inc @@ -144,6 +144,7 @@ static bool gen_load(DisasContext *ctx, arg_lb *a, MemOp memop) tcg_gen_addi_tl(temp, addr, a->imm); addr = temp; } + addr = gen_pm_adjust_address(ctx, addr); tcg_gen_qemu_ld_tl(dest, addr, ctx->mem_idx, memop); gen_set_gpr(ctx, a->rd, dest); @@ -185,6 +186,7 @@ static bool gen_store(DisasContext *ctx, arg_sb *a, MemOp memop) tcg_gen_addi_tl(temp, addr, a->imm); addr = temp; } + addr = gen_pm_adjust_address(ctx, addr); tcg_gen_qemu_st_tl(data, addr, ctx->mem_idx, memop); return true; From patchwork Thu Oct 28 04:43:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1547324 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=PZU4hQIX; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=ZASFsHr9; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hftjv0MP7z9sS8 for ; Thu, 28 Oct 2021 16:03:13 +1100 (AEDT) Received: from localhost ([::1]:51812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfxZG-000637-Bv for incoming@patchwork.ozlabs.org; Thu, 28 Oct 2021 01:03:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50968) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxHg-0000Zl-KI for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:45:01 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:13374) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxHe-00059i-DO for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:45:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1635396298; x=1666932298; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PnQisqF8wvDYvC7TlCLmo7Hr/56zj8ecORTw7H4Lz7w=; b=PZU4hQIX34nSSXbyTlzqb/eyvyJlbSvzyYw06iKhJHh2bxQuGy9iV0Nd wJMVBOnnAPAs5PQifTTu2MOzLWw72nBhCzsqXQ0caYBxMYqpAsFsgvO71 f+YkzmSHSkqUmXIQW94BlCEkeRt4Bo6ybQV9dZ0hrc9nTRUPhfA4a9uDA fkkMN91pnfwCUXydakxBIn/AzhulhPPJkIBMFghkwAu4MTqm/E4zCfiJD 00K4pkXuE3BoORKwOBa+7GLU1Cmi/oiVdh06AgjVNRxIUVKLqHu13Q2Uv PtmxxvqRL5RqGYK2Mr1F9xIwKgFqwgreahOEWXGgyfSZmrqiNuM2p7g7x A==; X-IronPort-AV: E=Sophos;i="5.87,188,1631548800"; d="scan'208";a="287922979" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 28 Oct 2021 12:44:57 +0800 IronPort-SDR: WQH1SIpeq9HEbgf8Az31M3Y9FyFDOIftemcAlqo0lyO1SI5ws1DY6+8nlqelVyY9ULF9YP/oxg wIvMqgR9APlgbxACkETcJXAcpmy2lA7sdSX3PeKYF3QFsU3AcjTTHc2HjejN8H5iClyB37kSLm SdslHT4B2cxVs45OPxjUlDsTf5KTO0MuYvxVeLc+TCLSwO6JCZB4QbbpnFFy7kxbTtplauH2Yl HqBRxnFlRp8zd0YK2DdDlseeEztZTpnlLRTdvlfajExM3l0KH2Y4pEn2TtQX6y8nSGqkcrjKYQ kqEYx+Nsp50KZq/V16u/V/BK Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:18:52 -0700 IronPort-SDR: mRxkgGFBAvbNcnuVdLv7cCyQ/wMJgCbbD1KP1ox0iJI40FE0Gt00uLnFWBPHac40BhzocHQBdc F/i6D5IHr7JlcDWARABiEcKAM1FhC30Z2CkbClRqa2G0f2arbFvjC2Hssoy02qr86PmnZW/nL0 rdgcscDMDiLEfeoSyX2JhCRD/NgUATCKB8jJ2K11knoFhNIoZghw7UnH/yLqNlVJ56yRBeQXlG PLw36/BuhKPbcfECQMAVOeuboMgF9Vv3HRHykNzpXrjrieN+CESnxrV6IGrirGwCT++JZ7+XxT 0uw= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:44:58 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HftJn3QYgz1RtVm for ; Wed, 27 Oct 2021 21:44:57 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1635396296; x=1637988297; bh=PnQisqF8wvDYvC7TlC Lmo7Hr/56zj8ecORTw7H4Lz7w=; b=ZASFsHr9GG1YjLcwGdhmgRAXbT0bOAtJ9r 9a+9oz3gQkDa8VTI0SLyGduJ8lvT+OVbWtNJCZIuUDa/yKZxpAnZG656qqWsdHPi cA5U1JpMSVDeRPPIh0hvlPmaPShO/ITfwMfe088LCQ2Kbo6M/8jtBhRcvcA4LRN5 91PkzbUjmcnkDTOd6b41W7+QZa+AHj3DC8aUvgRmGO7Vh8yr2b4AS81OcXkS9gjR pNNi/SEtZ678QCwiyi3IVptkOluGPxgBedtz7dC92Ac+qAXjt2+srVgbjXHsLdbF 3HWRyDQ8mWByEDSQrhTY6UM0MESFZv0cy13hQLQJlc7jJuUR9JJA== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id HvsBdfOc02tO for ; Wed, 27 Oct 2021 21:44:56 -0700 (PDT) Received: from toolbox.alistair23.me (unknown [10.225.165.40]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HftJj13X1z1RtVl; Wed, 27 Oct 2021 21:44:52 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Anatoly Parshintsev , Richard Henderson , Alistair Francis Subject: [PULL 13/18] target/riscv: Implement address masking functions required for RISC-V Pointer Masking extension Date: Thu, 28 Oct 2021 14:43:37 +1000 Message-Id: <20211028044342.3070385-14-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> References: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=68.232.143.124; envelope-from=prvs=928ee31ee=alistair.francis@opensource.wdc.com; helo=esa2.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Anatoly Parshintsev Signed-off-by: Anatoly Parshintsev Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis Message-id: 20211025173609.2724490-8-space.monkey.delivers@gmail.com Signed-off-by: Alistair Francis --- target/riscv/cpu.h | 2 ++ target/riscv/cpu_helper.c | 18 ++++++++++++++++++ target/riscv/translate.c | 39 +++++++++++++++++++++++++++++++++++++-- 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index b2422e3f99..325908287d 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -410,6 +410,8 @@ FIELD(TB_FLAGS, HLSX, 10, 1) FIELD(TB_FLAGS, MSTATUS_HS_FS, 11, 2) /* The combination of MXL/SXL/UXL that applies to the current cpu mode. */ FIELD(TB_FLAGS, XL, 13, 2) +/* If PointerMasking should be applied */ +FIELD(TB_FLAGS, PM_ENABLED, 15, 1) #ifdef TARGET_RISCV32 #define riscv_cpu_mxl(env) ((void)(env), MXL_RV32) diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 0d1132f39d..662228c238 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -107,6 +107,24 @@ void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc, flags = FIELD_DP32(flags, TB_FLAGS, MSTATUS_HS_FS, get_field(env->mstatus_hs, MSTATUS_FS)); } + if (riscv_has_ext(env, RVJ)) { + int priv = flags & TB_FLAGS_PRIV_MMU_MASK; + bool pm_enabled = false; + switch (priv) { + case PRV_U: + pm_enabled = env->mmte & U_PM_ENABLE; + break; + case PRV_S: + pm_enabled = env->mmte & S_PM_ENABLE; + break; + case PRV_M: + pm_enabled = env->mmte & M_PM_ENABLE; + break; + default: + g_assert_not_reached(); + } + flags = FIELD_DP32(flags, TB_FLAGS, PM_ENABLED, pm_enabled); + } #endif flags = FIELD_DP32(flags, TB_FLAGS, XL, cpu_get_xl(env)); diff --git a/target/riscv/translate.c b/target/riscv/translate.c index a5e6fa145d..1d57bc97b5 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -36,6 +36,9 @@ static TCGv cpu_gpr[32], cpu_pc, cpu_vl; static TCGv_i64 cpu_fpr[32]; /* assume F and D extensions */ static TCGv load_res; static TCGv load_val; +/* globals for PM CSRs */ +static TCGv pm_mask[4]; +static TCGv pm_base[4]; #include "exec/gen-icount.h" @@ -83,6 +86,10 @@ typedef struct DisasContext { TCGv zero; /* Space for 3 operands plus 1 extra for address computation. */ TCGv temp[4]; + /* PointerMasking extension */ + bool pm_enabled; + TCGv pm_mask; + TCGv pm_base; } DisasContext; static inline bool has_ext(DisasContext *ctx, uint32_t ext) @@ -272,11 +279,20 @@ static void gen_jal(DisasContext *ctx, int rd, target_ulong imm) } /* - * Temp stub: generates address adjustment for PointerMasking + * Generates address adjustment for PointerMasking */ static TCGv gen_pm_adjust_address(DisasContext *s, TCGv src) { - return src; + TCGv temp; + if (!s->pm_enabled) { + /* Load unmodified address */ + return src; + } else { + temp = temp_new(s); + tcg_gen_andc_tl(temp, src, s->pm_mask); + tcg_gen_or_tl(temp, temp, s->pm_base); + return temp; + } } #ifndef CONFIG_USER_ONLY @@ -622,6 +638,10 @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs) ctx->cs = cs; ctx->ntemp = 0; memset(ctx->temp, 0, sizeof(ctx->temp)); + ctx->pm_enabled = FIELD_EX32(tb_flags, TB_FLAGS, PM_ENABLED); + int priv = tb_flags & TB_FLAGS_PRIV_MMU_MASK; + ctx->pm_mask = pm_mask[priv]; + ctx->pm_base = pm_base[priv]; ctx->zero = tcg_constant_tl(0); } @@ -735,4 +755,19 @@ void riscv_translate_init(void) "load_res"); load_val = tcg_global_mem_new(cpu_env, offsetof(CPURISCVState, load_val), "load_val"); +#ifndef CONFIG_USER_ONLY + /* Assign PM CSRs to tcg globals */ + pm_mask[PRV_U] = + tcg_global_mem_new(cpu_env, offsetof(CPURISCVState, upmmask), "upmmask"); + pm_base[PRV_U] = + tcg_global_mem_new(cpu_env, offsetof(CPURISCVState, upmbase), "upmbase"); + pm_mask[PRV_S] = + tcg_global_mem_new(cpu_env, offsetof(CPURISCVState, spmmask), "spmmask"); + pm_base[PRV_S] = + tcg_global_mem_new(cpu_env, offsetof(CPURISCVState, spmbase), "spmbase"); + pm_mask[PRV_M] = + tcg_global_mem_new(cpu_env, offsetof(CPURISCVState, mpmmask), "mpmmask"); + pm_base[PRV_M] = + tcg_global_mem_new(cpu_env, offsetof(CPURISCVState, mpmbase), "mpmbase"); +#endif } From patchwork Thu Oct 28 04:43:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1547320 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=a4rRpbA0; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=HQNafoWB; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HftYz2Tnlz9sP7 for ; Thu, 28 Oct 2021 15:56:21 +1100 (AEDT) Received: from localhost ([::1]:39988 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfxSb-0006Bi-8d for incoming@patchwork.ozlabs.org; Thu, 28 Oct 2021 00:56:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50996) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxHn-0000jZ-M0 for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:45:09 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:42058) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxHk-0005Bg-EH for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:45:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1635396304; x=1666932304; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7MDnK/8FcSTvs8XMDX1+mff0lWevalZQvp/ZJL03XgA=; b=a4rRpbA0EpyVxsDD/AUnpQl0z7k1Hq1td9Ih+FiXUwwLuEJJ/fWpmpmI 48YTu+veQWB4U08DhnklERMkyQZegyyqRWdG8Pid3uLYvesXjgpo7b/7G Ln6mzI1PBn3lyytMY4wGIRDA5hOo/Sw6lQmS6/1N77WOGXfPcInW+a4Td kOMO3puoMIiT0e+sTUaoCS6s4zIWATEz2u9/sp4azNXDqNGg9bZL/1TfU OrI1ir4fHg29+oQxfy+KIhnoxqzbIHTRsdbh4fGUZSWn91MRD3Y1Qfq5z QMGB17e7Th1OJq0rp74Ssdhalutul7MQSlzwNttOO2N522RxUKtm7fNU/ g==; X-IronPort-AV: E=Sophos;i="5.87,188,1631548800"; d="scan'208";a="183044163" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 28 Oct 2021 12:45:03 +0800 IronPort-SDR: 0viTEZ/o2VoQB805WklYgy49Zom6876r+vqkiCScrCWZccCrS3IcF5c9x9bA46Q4yr4/W7fELy numNTuDpedbrz6LhZFMlfFRPECkZtqteA863WUBiQR11gK2EwTlM2Li/DM78jYP2TZUjPIStn5 B4Sgfxe9g2kdN8lW4kpqrq48M0OJC0X+3n6PoTs4ZT4iOi3cRPNpq2O4LUIwvhkoJJc8MogBN/ tggLYAVhw6cA9pPjF67WT5LmGVs0rdmeWp5tX/9hJa/Q2yf9JanbbqNQKQupGZ3ov5FTFsIajA 7no9cEIIc5esRq6ER751RCay Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:18:58 -0700 IronPort-SDR: tVlWWjsX2H0lj7LGf7fA/xUUp36ocx6FnmxG+4sBqnmOKqd0QlMl3CqImXG5qR4locFYcbcmRP uTavVN4b01Oio+fHnTb0hNfit3mNPFj2Osr7G50fR0Dv4uaBQxAW7/8IiapFjMW0sbroENPz/K QdX4lnVH2XJsAlXR87Ny+ceuvvD+gvF1Jjttw+o0/G6WbybYwpzDX4R2v6OUQnsYl1W9nEx1Kl CCuXPqY6YfxkCHi5LyaSUG3GIfuBasidtoUxt6H1yYZTUHUqrPKsovgMm63y7t02MXLkDjuAlL g1c= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:45:03 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HftJt6BXJz1RtVm for ; Wed, 27 Oct 2021 21:45:02 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1635396302; x=1637988303; bh=7MDnK/8FcSTvs8XMDX 1+mff0lWevalZQvp/ZJL03XgA=; b=HQNafoWBJJdcjhNduoUNnGQaIG36f4vvNm mRiottWp0yhacVopN4WIVJXKQRIrXz7t1ywC7ZBHkbFal7918Edp/sJ4kkBlfC+t /t06G/0cdAp8l8A9hYzReXP73PCpLUIBXvCBdg5BmkU4uPKdus7v0GTRI4ZP7etw EPisPVwHQhKlh0t9V2YMUyUjo3SSAZg0yHVoi+zzEPJKQcGD4b9SSCEzBhCwFZWy GQVBFcr/J763s309SRIGGuAyLaDsoJO2XzgbfgoMX15YLrdvyXWV5jBv3DSFD+lY E8aQQHlTpXrXAqypGGKuPleEXlxS0ns7QXyg+qssgd4LlSjxNVKg== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Im7FpBelvQ1R for ; Wed, 27 Oct 2021 21:45:02 -0700 (PDT) Received: from toolbox.alistair23.me (unknown [10.225.165.40]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HftJp1B56z1RtVl; Wed, 27 Oct 2021 21:44:57 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Alexey Baturo , Alexey Baturo , Alistair Francis , Bin Meng , Richard Henderson Subject: [PULL 14/18] target/riscv: Allow experimental J-ext to be turned on Date: Thu, 28 Oct 2021 14:43:38 +1000 Message-Id: <20211028044342.3070385-15-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> References: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=928ee31ee=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alexey Baturo Signed-off-by: Alexey Baturo Reviewed-by: Alistair Francis Reviewed-by: Bin Meng Reviewed-by: Richard Henderson Message-id: 20211025173609.2724490-9-space.monkey.delivers@gmail.com Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 16fac64806..7d53125dbc 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -562,6 +562,9 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) } set_vext_version(env, vext_version); } + if (cpu->cfg.ext_j) { + ext |= RVJ; + } set_misa(env, env->misa_mxl, ext); } @@ -637,6 +640,7 @@ static Property riscv_cpu_properties[] = { DEFINE_PROP_BOOL("x-zbc", RISCVCPU, cfg.ext_zbc, false), DEFINE_PROP_BOOL("x-zbs", RISCVCPU, cfg.ext_zbs, false), DEFINE_PROP_BOOL("x-h", RISCVCPU, cfg.ext_h, false), + DEFINE_PROP_BOOL("x-j", RISCVCPU, cfg.ext_j, false), DEFINE_PROP_BOOL("x-v", RISCVCPU, cfg.ext_v, false), DEFINE_PROP_STRING("vext_spec", RISCVCPU, cfg.vext_spec), DEFINE_PROP_UINT16("vlen", RISCVCPU, cfg.vlen, 128), From patchwork Thu Oct 28 04:43:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1547325 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=CsdXYpLZ; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=LBUrKClV; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HftlC2Tkjz9sS8 for ; Thu, 28 Oct 2021 16:04:23 +1100 (AEDT) Received: from localhost ([::1]:53974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfxaP-0007V0-5J for incoming@patchwork.ozlabs.org; Thu, 28 Oct 2021 01:04:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51046) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxHt-0000sG-Sr for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:45:14 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:42396) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxHr-0005CM-3A for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:45:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1635396309; x=1666932309; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WwHJ/ZVkBIipvA0SPzaWNs4FzpkkzsKcMKbxAl2+87k=; b=CsdXYpLZMWcoMaQoPN+0Np6uIRagTOwrUv0jmd/9PD/bnhDSfucfS5b4 OqcK1UrFnLCSdFMT4yzDBerC938u/homfcVsw7ANBIV7aPYvfiQJPTFak zcEd3repcpULZSNSoJuZOvkrbEHiJ9ZKBLx7BgmkGsr/h4FUxzVxfA4KM IokSp1aIfFluBkkEQqr73ozCAjdxVworytrphLiWtpO+IZOfBSas2TNAy 6hIUmhJzsOOPaekX7pANiS9BZDdYEQ0my2mPmrSh3/4U2rGo8C8yrWum9 SnzpVpw+sYQMPdYiCeMUAIDt/DoGJLaWVhiSSe13hwv4BeeLSP3P7DRBv Q==; X-IronPort-AV: E=Sophos;i="5.87,188,1631548800"; d="scan'208";a="188815810" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 28 Oct 2021 12:45:08 +0800 IronPort-SDR: WsJOOtNLg1KWukDyu3cwfHgAuzdjMhFsY+HxjHaH6FNoKS8nmICnQLYqMb5LGP0wGbS7/ywKlQ 2KJMN15vcVewvBLbuiP567Nbu2ASt9xrwVlz4k8/iZQLCTXb/lvce1xK9GSZUxslpi54X3yRS2 FR+9Mw08Bm5ruzSc6t83WhOd8//WC6Hm8RXw6Iq+jXn1adrY11p1p+3FZIFktZpVkVTEytVY6Y Qpaty2OYQkEkWf09kRFmI0TtLtlFJSr0g+dG+QDi2roK9QEmeFUKSVbvaC96Tiz2cNnUIpVhNG hdUa5R/swMcbV2wDepHmijry Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:19:04 -0700 IronPort-SDR: iNOnp1wBPoD02q+irrry2h9dW5JALmfaZCjo37GKdhuJgZni76KXQrwBMWGrnKXhfT9DCmczEn 2X2XzbFlK65GAmFnEYTSfPlD6OMfScLzRWisgz/pCBD1+YZtfo2mOFLBiatFoTd3GdrQ6YjLIT fkp6GOGeNVSEovlx7gIWv+37V9Kfsy2Vm4yQ5BYAgI62Ai9JB9fBUsOfcjh4lWL/0QEe9tgFC6 dzsy/+cwPuMbMFzwvl8KKVH4XPEf8Ws6iFFRHSKLwG/Q9u7qkU67q2bJYhOvZzkBs4siz1lOPv FAo= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:45:09 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HftK100lLz1RtVx for ; Wed, 27 Oct 2021 21:45:08 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1635396308; x=1637988309; bh=WwHJ/ZVkBIipvA0SPz aWNs4FzpkkzsKcMKbxAl2+87k=; b=LBUrKClV3+hYstiCUc8ifqBE4ccUKqrE4z tyXnj/xsAxZgaTKsJpELFWTHWOXIZQFQLe3GsKSgDWvxlGouHFG3U8/slGxGJkKY zpC1QS91ISBZJWqlZB5bvKxqhBlfaG+mdKFt/KHQtgCCssP7Kd6VG2dp870HVDnp rUoJMmvY8JLZ2y8+mDlYYK1CAVgj524HH8QfJSwhlMDqX0uIjCovLVOv1o1EPm2Y kDDf6IVxnDdH1SH6ENbb0cdp01pPs6LLwGdOxA9dNZl0LxbVrD4fCRsc52VG0iJj uJLaovXmBVnMnEiJUQ3DAm/776xXiYG18HsBttSCzp7foC60YZRQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id FeSB8M7fOvFc for ; Wed, 27 Oct 2021 21:45:08 -0700 (PDT) Received: from toolbox.alistair23.me (unknown [10.225.165.40]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HftJv4BZqz1RtVl; Wed, 27 Oct 2021 21:45:02 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Chih-Min Chao , Frank Chang , Richard Henderson , Alistair Francis Subject: [PULL 15/18] softfloat: add APIs to handle alternative sNaN propagation for fmax/fmin Date: Thu, 28 Oct 2021 14:43:39 +1000 Message-Id: <20211028044342.3070385-16-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> References: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.141; envelope-from=prvs=928ee31ee=alistair.francis@opensource.wdc.com; helo=esa3.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Chih-Min Chao For "fmax/fmin ft0, ft1, ft2" and if one of the inputs is sNaN, The original logic: Return NaN and set invalid flag if ft1 == sNaN || ft2 == sNan. The alternative path: Set invalid flag if ft1 == sNaN || ft2 == sNaN. Return NaN only if ft1 == NaN && ft2 == NaN. The IEEE 754 spec allows both implementation and some architecture such as riscv choose different defintions in two spec versions. (riscv-spec-v2.2 use original version, riscv-spec-20191213 changes to alternative) Signed-off-by: Chih-Min Chao Signed-off-by: Frank Chang Reviewed-by: Richard Henderson Message-id: 20211016085428.3001501-2-frank.chang@sifive.com Signed-off-by: Alistair Francis --- include/fpu/softfloat.h | 10 ++++++++++ fpu/softfloat.c | 19 +++++++++++++------ fpu/softfloat-parts.c.inc | 25 +++++++++++++++++++++++-- 3 files changed, 46 insertions(+), 8 deletions(-) diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index ec7dca0960..a249991e61 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -243,6 +243,8 @@ float16 float16_minnum(float16, float16, float_status *status); float16 float16_maxnum(float16, float16, float_status *status); float16 float16_minnummag(float16, float16, float_status *status); float16 float16_maxnummag(float16, float16, float_status *status); +float16 float16_minimum_number(float16, float16, float_status *status); +float16 float16_maximum_number(float16, float16, float_status *status); float16 float16_sqrt(float16, float_status *status); FloatRelation float16_compare(float16, float16, float_status *status); FloatRelation float16_compare_quiet(float16, float16, float_status *status); @@ -422,6 +424,8 @@ bfloat16 bfloat16_minnum(bfloat16, bfloat16, float_status *status); bfloat16 bfloat16_maxnum(bfloat16, bfloat16, float_status *status); bfloat16 bfloat16_minnummag(bfloat16, bfloat16, float_status *status); bfloat16 bfloat16_maxnummag(bfloat16, bfloat16, float_status *status); +bfloat16 bfloat16_minimum_number(bfloat16, bfloat16, float_status *status); +bfloat16 bfloat16_maximum_number(bfloat16, bfloat16, float_status *status); bfloat16 bfloat16_sqrt(bfloat16, float_status *status); FloatRelation bfloat16_compare(bfloat16, bfloat16, float_status *status); FloatRelation bfloat16_compare_quiet(bfloat16, bfloat16, float_status *status); @@ -589,6 +593,8 @@ float32 float32_minnum(float32, float32, float_status *status); float32 float32_maxnum(float32, float32, float_status *status); float32 float32_minnummag(float32, float32, float_status *status); float32 float32_maxnummag(float32, float32, float_status *status); +float32 float32_minimum_number(float32, float32, float_status *status); +float32 float32_maximum_number(float32, float32, float_status *status); bool float32_is_quiet_nan(float32, float_status *status); bool float32_is_signaling_nan(float32, float_status *status); float32 float32_silence_nan(float32, float_status *status); @@ -778,6 +784,8 @@ float64 float64_minnum(float64, float64, float_status *status); float64 float64_maxnum(float64, float64, float_status *status); float64 float64_minnummag(float64, float64, float_status *status); float64 float64_maxnummag(float64, float64, float_status *status); +float64 float64_minimum_number(float64, float64, float_status *status); +float64 float64_maximum_number(float64, float64, float_status *status); bool float64_is_quiet_nan(float64 a, float_status *status); bool float64_is_signaling_nan(float64, float_status *status); float64 float64_silence_nan(float64, float_status *status); @@ -1210,6 +1218,8 @@ float128 float128_minnum(float128, float128, float_status *status); float128 float128_maxnum(float128, float128, float_status *status); float128 float128_minnummag(float128, float128, float_status *status); float128 float128_maxnummag(float128, float128, float_status *status); +float128 float128_minimum_number(float128, float128, float_status *status); +float128 float128_maximum_number(float128, float128, float_status *status); bool float128_is_quiet_nan(float128, float_status *status); bool float128_is_signaling_nan(float128, float_status *status); float128 float128_silence_nan(float128, float_status *status); diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 6e769f990c..9a28720d82 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -436,6 +436,11 @@ enum { minmax_isnum = 2, /* Set for the IEEE 754-2008 minNumMag() and minNumMag() operations. */ minmax_ismag = 4, + /* + * Set for the IEEE 754-2019 minimumNumber() and maximumNumber() + * operations. + */ + minmax_isnumber = 8, }; /* Simple helpers for checking if, or what kind of, NaN we have */ @@ -3927,12 +3932,14 @@ static float128 float128_minmax(float128 a, float128 b, { return type##_minmax(a, b, s, flags); } #define MINMAX_2(type) \ - MINMAX_1(type, max, 0) \ - MINMAX_1(type, maxnum, minmax_isnum) \ - MINMAX_1(type, maxnummag, minmax_isnum | minmax_ismag) \ - MINMAX_1(type, min, minmax_ismin) \ - MINMAX_1(type, minnum, minmax_ismin | minmax_isnum) \ - MINMAX_1(type, minnummag, minmax_ismin | minmax_isnum | minmax_ismag) + MINMAX_1(type, max, 0) \ + MINMAX_1(type, maxnum, minmax_isnum) \ + MINMAX_1(type, maxnummag, minmax_isnum | minmax_ismag) \ + MINMAX_1(type, maximum_number, minmax_isnumber) \ + MINMAX_1(type, min, minmax_ismin) \ + MINMAX_1(type, minnum, minmax_ismin | minmax_isnum) \ + MINMAX_1(type, minnummag, minmax_ismin | minmax_isnum | minmax_ismag) \ + MINMAX_1(type, minimum_number, minmax_ismin | minmax_isnumber) \ MINMAX_2(float16) MINMAX_2(bfloat16) diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc index dddee92d6e..41d4b17e41 100644 --- a/fpu/softfloat-parts.c.inc +++ b/fpu/softfloat-parts.c.inc @@ -1219,14 +1219,35 @@ static FloatPartsN *partsN(minmax)(FloatPartsN *a, FloatPartsN *b, if (unlikely(ab_mask & float_cmask_anynan)) { /* - * For minnum/maxnum, if one operand is a QNaN, and the other + * For minNum/maxNum (IEEE 754-2008) + * or minimumNumber/maximumNumber (IEEE 754-2019), + * if one operand is a QNaN, and the other * operand is numerical, then return numerical argument. */ - if ((flags & minmax_isnum) + if ((flags & (minmax_isnum | minmax_isnumber)) && !(ab_mask & float_cmask_snan) && (ab_mask & ~float_cmask_qnan)) { return is_nan(a->cls) ? b : a; } + + /* + * In IEEE 754-2019, minNum, maxNum, minNumMag and maxNumMag + * are removed and replaced with minimum, minimumNumber, maximum + * and maximumNumber. + * minimumNumber/maximumNumber behavior for SNaN is changed to: + * If both operands are NaNs, a QNaN is returned. + * If either operand is a SNaN, + * an invalid operation exception is signaled, + * but unless both operands are NaNs, + * the SNaN is otherwise ignored and not converted to a QNaN. + */ + if ((flags & minmax_isnumber) + && (ab_mask & float_cmask_snan) + && (ab_mask & ~float_cmask_anynan)) { + float_raise(float_flag_invalid, s); + return is_nan(a->cls) ? b : a; + } + return parts_pick_nan(a, b, s); } From patchwork Thu Oct 28 04:43:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1547318 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=QtPP53W5; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=aMHZEXZD; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HftW71KM9z9sP7 for ; Thu, 28 Oct 2021 15:53:55 +1100 (AEDT) Received: from localhost ([::1]:35500 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfxQG-0003An-Ve for incoming@patchwork.ozlabs.org; Thu, 28 Oct 2021 00:53:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51072) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxHx-0000xz-F9 for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:45:17 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:42396) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxHv-0005CM-6h for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:45:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1635396313; x=1666932313; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Bqz2jkcGkqug32R6T6pWv96TjmImip+gfc3yBS0PtSc=; b=QtPP53W5JmQCFX+4H76WEY8b1EDWD3iWVG48VsmjHIkIj9yxrK8UYbRH jqOOYYqJ4TzX7hgQ3xLOipGGOX7k9V0wgdIurQ/fmbt3EA7QpePWueGw0 +c1QlLEpEzO0vae0VWjWCNE4adD++pEZnQ54iiQmp2eNLrvakC8kXlJem yQgff5GTzWGcVaqB980zlDDXckvOFSkMXOw0PSe0IFZ465psVel+riTMJ /iB4p+sJIrwKKofYU5e/9b1v+teqZGBW558jJn6HGdflA/U8THdKip2WV T/u6/slvlaYz9m9uvDI9KyCC8IXJ0mHGQWAaYPHT/sexVL6mUsijfxmw7 w==; X-IronPort-AV: E=Sophos;i="5.87,188,1631548800"; d="scan'208";a="188815819" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 28 Oct 2021 12:45:13 +0800 IronPort-SDR: dunWZKVXtQgnm0JtdFBsO72SwsmgG2D1SWovC4d7wmd+jBsfaPv72zT1Uz+bJELZrVUixFlIYL y4H1DDeljVoIkuHcN4gLXlBeI4+HomhL4YGluapNFhOhwpWTLGfTkFZo70qb58RkcJRQQISnT3 CBtPx9Iq5qKDP9VaTxnfKRH/llo3UTZG5c14lGjVmkleeBhAnVf7nWW8xaI8FlKMU7FM3G94/W 8Koe0xUAx905ZZRbJLnsQSbt8mgy6/KKhTKv6MUjTtVKcaHELJDe+NqMHsGnfdrLBw9mE4fQsM QNzXbDtkoYzq9ci6Zn2BESkh Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:19:09 -0700 IronPort-SDR: fJOjZUEj97TjBiTpKLwmNhp3gSH3nIRjeKM7XukLUMhRfuka/v7NLF8VyqphCWFrIZyBOKpqMF PF/N/EIRcQWwPYEMei+jWEoEDTY9Jh7TmF1hVCtWLDWVP4dWNBiLAy8pzze9gCWIGpxL+dxlq8 GjvbghIqOgQdwXXwSCD65C16ETcgsk0w8aAB4i+EhguDvFANCWMpxJbILXqvNpqCtRGLs3ZfEl dA0+gJ4RSzV5wJlKwV4TKbkgfxTSeNtclPfpDEyGmC63JaDwifFKGAwdxOvYRkDNmYAGpOtviV 3ug= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:45:14 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HftK56T1Pz1RtVn for ; Wed, 27 Oct 2021 21:45:13 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1635396313; x=1637988314; bh=Bqz2jkcGkqug32R6T6 pWv96TjmImip+gfc3yBS0PtSc=; b=aMHZEXZDXUXR05XyvdC9UVR7dD8MR4GHQS zTpW0SP84plcXN7xcjl9ngbMxHZ6IQJRkYAnvK/MFvt1LYt7hWFgzRY0FF7HXjxi eH16LlMdBqHtZyhMTm0bRxJwGRJS1oVrbttx0fORTKMJP21XLldqfureNzSmOm5j EhqsLgFZbxdLDJpHX0k7UtHag/4TcBIJR/OX6zSmIrbo6ldNHWoKT5E/4XZlxgvP SIK/NFSgfxKBIGzLui2oJgMWa5jO/7u+48vjVdO0YuB5++2Qa4ZW66eG7t/mBX54 AW8m+Z/bfSvmb7bfUVE64rhTqLiI0JggsvhiGuN4qShVptFtVKoA== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id F9pRKx0NQfZT for ; Wed, 27 Oct 2021 21:45:13 -0700 (PDT) Received: from toolbox.alistair23.me (unknown [10.225.165.40]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HftK11W7hz1RtVl; Wed, 27 Oct 2021 21:45:08 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Chih-Min Chao , Frank Chang , Alistair Francis Subject: [PULL 16/18] target/riscv: change the api for RVF/RVD fmin/fmax Date: Thu, 28 Oct 2021 14:43:40 +1000 Message-Id: <20211028044342.3070385-17-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> References: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.141; envelope-from=prvs=928ee31ee=alistair.francis@opensource.wdc.com; helo=esa3.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Chih-Min Chao The sNaN propagation behavior has been changed since cd20cee7 in https://github.com/riscv/riscv-isa-manual. Signed-off-by: Chih-Min Chao Signed-off-by: Frank Chang Acked-by: Alistair Francis Message-id: 20211016085428.3001501-3-frank.chang@sifive.com Signed-off-by: Alistair Francis --- target/riscv/fpu_helper.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/target/riscv/fpu_helper.c b/target/riscv/fpu_helper.c index 8700516a14..d62f470900 100644 --- a/target/riscv/fpu_helper.c +++ b/target/riscv/fpu_helper.c @@ -174,14 +174,18 @@ uint64_t helper_fmin_s(CPURISCVState *env, uint64_t rs1, uint64_t rs2) { float32 frs1 = check_nanbox_s(rs1); float32 frs2 = check_nanbox_s(rs2); - return nanbox_s(float32_minnum(frs1, frs2, &env->fp_status)); + return nanbox_s(env->priv_ver < PRIV_VERSION_1_11_0 ? + float32_minnum(frs1, frs2, &env->fp_status) : + float32_minimum_number(frs1, frs2, &env->fp_status)); } uint64_t helper_fmax_s(CPURISCVState *env, uint64_t rs1, uint64_t rs2) { float32 frs1 = check_nanbox_s(rs1); float32 frs2 = check_nanbox_s(rs2); - return nanbox_s(float32_maxnum(frs1, frs2, &env->fp_status)); + return nanbox_s(env->priv_ver < PRIV_VERSION_1_11_0 ? + float32_maxnum(frs1, frs2, &env->fp_status) : + float32_maximum_number(frs1, frs2, &env->fp_status)); } uint64_t helper_fsqrt_s(CPURISCVState *env, uint64_t rs1) @@ -283,12 +287,16 @@ uint64_t helper_fdiv_d(CPURISCVState *env, uint64_t frs1, uint64_t frs2) uint64_t helper_fmin_d(CPURISCVState *env, uint64_t frs1, uint64_t frs2) { - return float64_minnum(frs1, frs2, &env->fp_status); + return env->priv_ver < PRIV_VERSION_1_11_0 ? + float64_minnum(frs1, frs2, &env->fp_status) : + float64_minimum_number(frs1, frs2, &env->fp_status); } uint64_t helper_fmax_d(CPURISCVState *env, uint64_t frs1, uint64_t frs2) { - return float64_maxnum(frs1, frs2, &env->fp_status); + return env->priv_ver < PRIV_VERSION_1_11_0 ? + float64_maxnum(frs1, frs2, &env->fp_status) : + float64_maximum_number(frs1, frs2, &env->fp_status); } uint64_t helper_fcvt_s_d(CPURISCVState *env, uint64_t rs1) From patchwork Thu Oct 28 04:43:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1547326 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=r3Ipv7QO; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=jScEq1wh; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HftnN2XHnz9sS8 for ; Thu, 28 Oct 2021 16:06:16 +1100 (AEDT) Received: from localhost ([::1]:56352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfxcE-0000hK-5j for incoming@patchwork.ozlabs.org; Thu, 28 Oct 2021 01:06:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51108) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxI1-0001As-O4 for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:45:21 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:42396) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxHz-0005CM-Hv for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:45:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1635396318; x=1666932318; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=W7oMGLcX+AkD/y2P+BS1j3A9Z2Cmw5E00UfbyUS7hiA=; b=r3Ipv7QOLkcHG5qfRedLWuKklqlrBM81M2glbGWv8kKVBFFMxDNsvZ0V suAaoLSvWprGg0UR3PF2qSFy8ujZxKYlB1QaNKY7IoqttV1GR8UYYRNMX xlMki9gc3pM71LVniRDxAD6hMlUfxPjA+t9g+CJmEOS1ytod3InQC+mC4 XUBW6rnRc/GQUn4nsnyppjwa11X686ps489XafR1kpmXCB9h9J/dFDjQN bK3CIQm1IkfXjrNiJU9s1lBWkZN2kJRk8h7e3GZ7x3Vd/VmTqy9CwY33L b/yVpJxCpWhsZipJ8QwEuyXL99gTm9SnKjjXfykSTuIUUA5shjtZuwQj1 w==; X-IronPort-AV: E=Sophos;i="5.87,188,1631548800"; d="scan'208";a="188815821" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 28 Oct 2021 12:45:17 +0800 IronPort-SDR: WS4KSC3mYdm5XvQQTc//36csLrJeKEoQnKeoK2qqAzSnJT+en+AUA2WPSoo8QGyjsLJSdaYFKl PQPjP+iJW+E79fkgyicgkcJO+7plXzjo8UTAGGaysBvFDraMgbS8afO/rmI0SHtVXJKLyhej66 kamnIFOOLh4laAYYB/ZFvsDyFF9Dt+iQymJb0RbEzId3WTSXD9z0gGOqnIHC1GBin++9rv5Ybk Af5F9afOaJrUDhD1/oPfDwvUXLlsHWipyfUplGyYS10kYssH2+KIwOnV2voaB7l/hj89R0TxPX ZoVj94ycBTUCpBwyMgv5w+mW Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:19:13 -0700 IronPort-SDR: 5UqtuiJ4+7ewsadXsuo6qedJOuv+qzYICuciF1APnpCdom9kcey7Y0+NRbsaxeyKs+EZhbKfQg QGijAXuwg5DV+Z5v67KQ2u+muZs1PD+fcpf7ctO7mhoSrC4TOUxIzMXNd8HLZoy9vkDhmcWuKe MIV9x06R8M2pJ8fFy5olWKk++dfg3nr4aDye6LfMc452EsyfLDIg42Or0Z8nS5Wre6jctas+/u zvBDMFCL5GW7GgIZohNkui3LeNAiKSiQFj9XMN5qSPkrgcQrXtMof/2SQ7/CvMdwUkmY0aeTZy dKU= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:45:19 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HftKB3VQxz1RtVn for ; Wed, 27 Oct 2021 21:45:18 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1635396317; x=1637988318; bh=W7oMGLcX+AkD/y2P+B S1j3A9Z2Cmw5E00UfbyUS7hiA=; b=jScEq1whPQBokB2yaWHl7T7S5reLy1OH3/ mAhzyjP7Ay0Aplw92reaqrHPSpgowvflWYYA0svWUwfqU4ztjpLF5/Mm43DHnEiF t/3CtOKCULLQKDbRQlE1thj2XObm7W5/deJb5lgcrAmTIuHlJ0GdgvupAoKvPGqZ 9zKyxvRENUD11QzY29F2dUEmLaZWw9Dyto89G3I791p937oEodeK8NnXWWFCbOJx cwapWBVe9f8f/GLZENdFYQzTmSYJn53YNClUl7bbcJt+KXNHQX5atqwWmJUeHAXN gnvqvihNQH4Hv0nN/T2/H1q+FB01fHEDzJ1nnESZiB0bfvcLtXdQ== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Hd5Xt9s8BpZh for ; Wed, 27 Oct 2021 21:45:17 -0700 (PDT) Received: from toolbox.alistair23.me (unknown [10.225.165.40]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HftK64X3rz1RtVl; Wed, 27 Oct 2021 21:45:13 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Jose Martins , Alistair Francis Subject: [PULL 17/18] target/riscv: fix VS interrupts forwarding to HS Date: Thu, 28 Oct 2021 14:43:41 +1000 Message-Id: <20211028044342.3070385-18-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> References: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.141; envelope-from=prvs=928ee31ee=alistair.francis@opensource.wdc.com; helo=esa3.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Jose Martins VS interrupts (2, 6, 10) were not correctly forwarded to hs-mode when not delegated in hideleg (which was not being taken into account). This was mainly because hs level sie was not always considered enabled when it should. The spec states that "Interrupts for higher-privilege modes, y>x, are always globally enabled regardless of the setting of the global yIE bit for the higher-privilege mode." and also "For purposes of interrupt global enables, HS-mode is considered more privileged than VS-mode, and VS-mode is considered more privileged than VU-mode". Also, vs-level interrupts were not being taken into account unless V=1, but should be unless delegated. Finally, there is no need for a special case for to handle vs interrupts as the current privilege level, the state of the global ie and of the delegation registers should be enough to route all interrupts to the appropriate privilege level in riscv_cpu_do_interrupt. Signed-off-by: Jose Martins Reviewed-by: Alistair Francis Message-id: 20211026145126.11025-2-josemartins90@gmail.com Signed-off-by: Alistair Francis --- target/riscv/cpu_helper.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 662228c238..5076580374 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -135,36 +135,24 @@ void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc, #ifndef CONFIG_USER_ONLY static int riscv_cpu_local_irq_pending(CPURISCVState *env) { - target_ulong irqs; + target_ulong virt_enabled = riscv_cpu_virt_enabled(env); target_ulong mstatus_mie = get_field(env->mstatus, MSTATUS_MIE); target_ulong mstatus_sie = get_field(env->mstatus, MSTATUS_SIE); - target_ulong hs_mstatus_sie = get_field(env->mstatus_hs, MSTATUS_SIE); - target_ulong pending = env->mip & env->mie & - ~(MIP_VSSIP | MIP_VSTIP | MIP_VSEIP); - target_ulong vspending = (env->mip & env->mie & - (MIP_VSSIP | MIP_VSTIP | MIP_VSEIP)); + target_ulong pending = env->mip & env->mie; target_ulong mie = env->priv < PRV_M || (env->priv == PRV_M && mstatus_mie); target_ulong sie = env->priv < PRV_S || (env->priv == PRV_S && mstatus_sie); - target_ulong hs_sie = env->priv < PRV_S || - (env->priv == PRV_S && hs_mstatus_sie); + target_ulong hsie = virt_enabled || sie; + target_ulong vsie = virt_enabled && sie; - if (riscv_cpu_virt_enabled(env)) { - target_ulong pending_hs_irq = pending & -hs_sie; - - if (pending_hs_irq) { - riscv_cpu_set_force_hs_excep(env, FORCE_HS_EXCEP); - return ctz64(pending_hs_irq); - } - - pending = vspending; - } - - irqs = (pending & ~env->mideleg & -mie) | (pending & env->mideleg & -sie); + target_ulong irqs = + (pending & ~env->mideleg & -mie) | + (pending & env->mideleg & ~env->hideleg & -hsie) | + (pending & env->mideleg & env->hideleg & -vsie); if (irqs) { return ctz64(irqs); /* since non-zero */ From patchwork Thu Oct 28 04:43:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 1547327 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=PG9CW7jQ; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.a=rsa-sha256 header.s=dkim header.b=RVVkJqHw; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hftqk1Jh2z9sS8 for ; Thu, 28 Oct 2021 16:08:16 +1100 (AEDT) Received: from localhost ([::1]:58574 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mfxe9-0002G5-BE for incoming@patchwork.ozlabs.org; Thu, 28 Oct 2021 01:08:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51126) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxI9-0001Ll-N9 for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:45:29 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:42396) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfxI3-0005CM-BY for qemu-devel@nongnu.org; Thu, 28 Oct 2021 00:45:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1635396322; x=1666932322; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uT0cvGbgwLHa6h/L8pMyTB93NNsouaRxSleBwq0/OVI=; b=PG9CW7jQzKI3BYKtiOxMLiJYump6LdwNY3CuZEctDNvBHv1Wa65sxuQs w5gK5S3qCJMtKcxWImLwI0zwiEA8va6dzZAs6qPZJEMBw/LgbJKRELkAh vlnrzfvd+gTMcbqR3cX3R02+daZs/QfB0uu61DMcm4n3JeUZO03Da/h3z lICMH2Qu64TPNsKQiOBOiGnq0sMrg+2+fweYtRJXsOBCv0KopJGoMRmDv 6M0PzUwiZoQsSarbE9DuKSBm396z9wCyy09vFAyq2BKqLepqMLed2QP/f HFVyRnru/av4UDjVEcFEJX/oJanTYKqvR7o7NnKKldVaPmIkO3KspcWhT g==; X-IronPort-AV: E=Sophos;i="5.87,188,1631548800"; d="scan'208";a="188815826" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 28 Oct 2021 12:45:21 +0800 IronPort-SDR: WAmJyoCbpE8qsVtnpc2wrArns8cpzUY6edI9ICQ4CWgfOuibBzFKx/M2lOO8purx3fTqKN/+wc L+mb7xmBBMYibjmyyHH5f4EjC+7ZYFhbVlrAtMse3AgO3BL39Hdb2R9O3qqgztbADsBEMFGV6H fvxzPkQy1nKN2vDFSml+h7TMSJAFp0ZCIKLBEuSlFgYworMP751IqoM0Vey1ZoqYPN6eRGOXiw uswvWGPMrAaoD0HNyzlzkmw88LSZh0UIheW9Za3P+hF64WT0Wj5iclcCy9qHvJZ4UE/ZXT9mMP HFGUYHd2ShHoFp9e9k3yaFfA Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:19:17 -0700 IronPort-SDR: 8uiuwIQzzZOVUa6i7SL/LzZGouTYov1w/gcsNd+H8lCc7WHP6gaegrpWaFelSN135u6/+acf2A 7ep/hbmQt6zh67En9GwW+kyaKdGaf2s5kpFU2Sl8qCuANq6mPB1rg4qyCbTzLantXO9krPAV9X WMlRv5Lt1YXfpjP/0SiTOaXuEDBhr+WxrlA+vll2n0yC8N5um2x0QiX06d7BJ8aMInqXmg6PN1 LW0C/PlSRR2+fz3ngL74M5fblWoQyqk6PaqvxkPDD+2YDSywmUnPNvS8RVqG4BZtdwRf4v9/N6 tJc= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2021 21:45:22 -0700 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4HftKG2BTVz1RtVp for ; Wed, 27 Oct 2021 21:45:22 -0700 (PDT) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:subject:to :from; s=dkim; t=1635396321; x=1637988322; bh=uT0cvGbgwLHa6h/L8p MyTB93NNsouaRxSleBwq0/OVI=; b=RVVkJqHwn/oiAuCdXXwKSJSJOpU8eFiX54 bU5+dpiS9vqWQtiIUl0ibdlmcvrDN22tzhIg8Wj/ZaGTj8ze0zXg9rrN6YotYKuP GLuX4GbY61NtBPFOoD6p9ZugKdPaHaR427BrgswFMwbvCw2GNsEUa7eGtT0NCkYi /h4Jjv4O0At86X6cFCr15D3+YaO00gFtopTVIhtmu+Qw0bRoY5uBFj3LNjKX+0ig URD8KBFlLH8sNMo90+ckiHJS4maOtG0nul6QmVBXxjPUSN0o6cNJw+FjeVABUbjR tEsnQxCGJDDlJXAt4sinFTIbsZfvPddv+zO9qnz4YRHdvAeZiItg== X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id GFAKtZR3xEoa for ; Wed, 27 Oct 2021 21:45:21 -0700 (PDT) Received: from toolbox.alistair23.me (unknown [10.225.165.40]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4HftKB5mL7z1RtVl; Wed, 27 Oct 2021 21:45:18 -0700 (PDT) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Jose Martins , Alistair Francis Subject: [PULL 18/18] target/riscv: remove force HS exception Date: Thu, 28 Oct 2021 14:43:42 +1000 Message-Id: <20211028044342.3070385-19-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> References: <20211028044342.3070385-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.141; envelope-from=prvs=928ee31ee=alistair.francis@opensource.wdc.com; helo=esa3.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Jose Martins There is no need to "force an hs exception" as the current privilege level, the state of the global ie and of the delegation registers should be enough to route the interrupt to the appropriate privilege level in riscv_cpu_do_interrupt. The is true for both asynchronous and synchronous exceptions, specifically, guest page faults which must be hardwired to zero hedeleg. As such the hs_force_except mechanism can be removed. Signed-off-by: Jose Martins Reviewed-by: Alistair Francis Message-id: 20211026145126.11025-3-josemartins90@gmail.com Signed-off-by: Alistair Francis --- target/riscv/cpu.h | 2 -- target/riscv/cpu_bits.h | 6 ------ target/riscv/cpu_helper.c | 26 +------------------------- 3 files changed, 1 insertion(+), 33 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 325908287d..0760c0af93 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -352,8 +352,6 @@ int riscv_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); bool riscv_cpu_fp_enabled(CPURISCVState *env); bool riscv_cpu_virt_enabled(CPURISCVState *env); void riscv_cpu_set_virt_enabled(CPURISCVState *env, bool enable); -bool riscv_cpu_force_hs_excep_enabled(CPURISCVState *env); -void riscv_cpu_set_force_hs_excep(CPURISCVState *env, bool enable); bool riscv_cpu_two_stage_lookup(int mmu_idx); int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch); hwaddr riscv_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index aa0bce4e06..9913fa9f77 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -444,12 +444,6 @@ typedef enum { /* Virtulisation Register Fields */ #define VIRT_ONOFF 1 -/* This is used to save state for when we take an exception. If this is set - * that means that we want to force a HS level exception (no matter what the - * delegation is set to). This will occur for things such as a second level - * page table fault. - */ -#define FORCE_HS_EXCEP 2 /* RV32 satp CSR field masks */ #define SATP32_MODE 0x80000000 diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 5076580374..f30ff672f8 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -270,24 +270,6 @@ void riscv_cpu_set_virt_enabled(CPURISCVState *env, bool enable) env->virt = set_field(env->virt, VIRT_ONOFF, enable); } -bool riscv_cpu_force_hs_excep_enabled(CPURISCVState *env) -{ - if (!riscv_has_ext(env, RVH)) { - return false; - } - - return get_field(env->virt, FORCE_HS_EXCEP); -} - -void riscv_cpu_set_force_hs_excep(CPURISCVState *env, bool enable) -{ - if (!riscv_has_ext(env, RVH)) { - return; - } - - env->virt = set_field(env->virt, FORCE_HS_EXCEP, enable); -} - bool riscv_cpu_two_stage_lookup(int mmu_idx) { return mmu_idx & TB_FLAGS_PRIV_HYP_ACCESS_MASK; @@ -1004,7 +986,6 @@ void riscv_cpu_do_interrupt(CPUState *cs) RISCVCPU *cpu = RISCV_CPU(cs); CPURISCVState *env = &cpu->env; - bool force_hs_execp = riscv_cpu_force_hs_excep_enabled(env); uint64_t s; /* cs->exception is 32-bits wide unlike mcause which is XLEN-bits wide @@ -1033,8 +1014,6 @@ void riscv_cpu_do_interrupt(CPUState *cs) case RISCV_EXCP_INST_GUEST_PAGE_FAULT: case RISCV_EXCP_LOAD_GUEST_ACCESS_FAULT: case RISCV_EXCP_STORE_GUEST_AMO_ACCESS_FAULT: - force_hs_execp = true; - /* fallthrough */ case RISCV_EXCP_INST_ADDR_MIS: case RISCV_EXCP_INST_ACCESS_FAULT: case RISCV_EXCP_LOAD_ADDR_MIS: @@ -1093,8 +1072,7 @@ void riscv_cpu_do_interrupt(CPUState *cs) env->hstatus = set_field(env->hstatus, HSTATUS_GVA, 0); } - if (riscv_cpu_virt_enabled(env) && ((hdeleg >> cause) & 1) && - !force_hs_execp) { + if (riscv_cpu_virt_enabled(env) && ((hdeleg >> cause) & 1)) { /* Trap to VS mode */ /* * See if we need to adjust cause. Yes if its VS mode interrupt @@ -1116,7 +1094,6 @@ void riscv_cpu_do_interrupt(CPUState *cs) htval = env->guest_phys_fault_addr; riscv_cpu_set_virt_enabled(env, 0); - riscv_cpu_set_force_hs_excep(env, 0); } else { /* Trap into HS mode */ env->hstatus = set_field(env->hstatus, HSTATUS_SPV, false); @@ -1152,7 +1129,6 @@ void riscv_cpu_do_interrupt(CPUState *cs) /* Trapping to M mode, virt is disabled */ riscv_cpu_set_virt_enabled(env, 0); - riscv_cpu_set_force_hs_excep(env, 0); } s = env->mstatus;