From patchwork Wed Aug 12 22:30:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 247646 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp770975ilo; Wed, 12 Aug 2020 15:43:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhgCwce59pG3CGLpTzUNN4P85uFA0OWi5I3DgNn5EFTDZ1hSHSO39QrQkFbN7gm2fcZ7Uw X-Received: by 2002:a25:3803:: with SMTP id f3mr2450526yba.470.1597272231011; Wed, 12 Aug 2020 15:43:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597272231; cv=none; d=google.com; s=arc-20160816; b=tcRXpZHQ2VghHLvAIgi8DpQ7rq+s4wU94TojeD148mc4vPcnHCzNCtksvAhjhm6Pe3 ZRLsuUKvjj/TS+DURS+4cSlaFHS0nv+rorG88xitmJXBCRH8E4NLl2fw20USyYlOMzh4 i7nVQmslots7C5N3kN91gfjDpON/6XHhv/eucaFyEvcyZl0EkYl9Yh7jO3JxCU0sAXu4 qJybif49lMFRiBDBayP1N4TmmvgnWEdvC1lfS6yQTUq3texUxU78mW/VbeEe1oO4vkVr 4E0Y1qlxaZepgjWJoRvcmXk5xh5T9ZlpPDOOO61Tuh+rHPXf0UODPZQiJLL4tcWl4A4q Xmiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :wdcironportexception:ironport-sdr:ironport-sdr:ironport-sdr :dkim-signature; bh=WT6MO139MOesnh4+0DZYz+ad9KpIDjBNkI2OJGxR868=; b=rNv1Mw0TQxpdRHJi5Q2pTPUWgasQlt8wqtPs41KZj8r4ONBWqDeCnItXJaBHHzmSJp ILO0EqTLL4mC+T4BW/ZKR7Rby03ErZ5tZbf4Y823vkphC2xmtks+P8doZeR/MqjI7Uvi wssxIkxbRJkNFH+NMSa7oWCpNa7f7ZCD8AM1c2n6zlAjgJ2Iro+iq5hdVCediHqshvfj 6QhT9sbf5HjyFG50FISLZjKPSuCEPxdTIzY8qPUheURMu3B5E5CZ96fskXJrlAQ0K69t 6lmvSft6MVX0bJQLiAz86gz9DQp119ASU7U+VeNxwALMJ1Ph//rzb1u+iJgBYBV6qTmK atlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=mBBJ90Mr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n188si3526672yba.312.2020.08.12.15.43.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Aug 2020 15:43:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=mBBJ90Mr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Received: from localhost ([::1]:39890 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5zTK-0005eg-EI for patch@linaro.org; Wed, 12 Aug 2020 18:43:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39446) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQT-0002G6-JO for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:40:53 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:56479) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQQ-0005mK-0t for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:40:53 -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=1597272050; x=1628808050; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/sYwq4jJBFVrhAN6HvnU9aC89Zg8os3gcPnGisptQJw=; b=mBBJ90MrBvWyJ3f2lWXUrNwNIuRPzWKJsEYRo9RTjSmG61YnDRna39F+ wzg+GC6t8oq6PENPuR8bwztWaI4RZPmQHJrm9qJR6I4UA6qWppoFvBZK8 XKSxKCo12umpwnffjhsbn5MzuMzUFygJoEkG9rXDMyS/9RZuUoVWkfN96 hb4sFRbjMrSgmLS3PRyQBUHxB4RUz5XQMvr03VHOUEuHQ3kgjAryfMb8z BpsrZd/shFavGHBB32fmLrl0x7Off/ieuvWSzEWtvWgF+aLKBatFr5PZ6 1P/hy/b1AX3nTW8eKkWo5UWD92klnLiLHLf2TKVuisthrG3h7N0EXTMDl g==; IronPort-SDR: UwQhcaXd3NKmw789Tf4mrCYZ0rFJ6tgYptaBcsBQQ1k089antaB/RjbCRAxaKPnvAB0FsD2zoZ Kanzgg0Hnp3FIPhZQGqh/ZbharDWEYXLQK18QOmry4HBcB+73oPQ/ML/cmjYx+NMqM6t7rl6V6 PCsZmBAe9Tb9vgUwxZ1DJJAqECt76n1xi8dnrOwjYlwhXBaKuyY08hMfLisGxnBZ2St2RvOVxM q/r+R+P0UCcsJEWihga2zuyioz1LR+s0/Zzdfjy6I7gOAC2k3sQLdxmKsrHlkTZ67jDM36rI+E xGI= X-IronPort-AV: E=Sophos;i="5.76,305,1592841600"; d="scan'208";a="144853390" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 13 Aug 2020 06:40:47 +0800 IronPort-SDR: JkJzWU0ElCHVdrhoc7w/6sEo/CuOOIUI0jaENcKDZvCJGRj17G2NmF2fP5K1CFSeqgeR99ktXw AQ/baa3UIN1Q== Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 15:28:38 -0700 IronPort-SDR: 8SiIO+Ee6UoeuDOlGgCjljMtx3khNKQfqen4eCpPre+4tSo/1U+u81Fx45dr48fMdBUMlkVcoV nvDVYY/OcAAw== WDCIronportException: Internal Received: from jbfyk72.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.59.14]) by uls-op-cesaip01.wdc.com with ESMTP; 12 Aug 2020 15:40:44 -0700 From: Alistair Francis To: qemu-devel@nongnu.org Subject: [PULL 01/20] target/riscv: Generate nanboxed results from fp helpers Date: Wed, 12 Aug 2020 15:30:26 -0700 Message-Id: <20200812223045.96803-2-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200812223045.96803-1-alistair.francis@wdc.com> References: <20200812223045.96803-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=486123ee4=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/12 18:40:47 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] 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, URIBL_BLOCKED=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: , Cc: Alistair Francis , Richard Henderson , LIU Zhiwei Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Make sure that all results from single-precision scalar helpers are properly nan-boxed to 64-bits. Signed-off-by: Richard Henderson Reviewed-by: LIU Zhiwei Message-Id: <20200724002807.441147-2-richard.henderson@linaro.org> Signed-off-by: Alistair Francis --- target/riscv/internals.h | 5 +++++ target/riscv/fpu_helper.c | 42 +++++++++++++++++++++------------------ 2 files changed, 28 insertions(+), 19 deletions(-) -- 2.27.0 diff --git a/target/riscv/internals.h b/target/riscv/internals.h index 37d33820ad..9f4ba7d617 100644 --- a/target/riscv/internals.h +++ b/target/riscv/internals.h @@ -38,4 +38,9 @@ target_ulong fclass_d(uint64_t frs1); #define SEW32 2 #define SEW64 3 +static inline uint64_t nanbox_s(float32 f) +{ + return f | MAKE_64BIT_MASK(32, 32); +} + #endif diff --git a/target/riscv/fpu_helper.c b/target/riscv/fpu_helper.c index 4379756dc4..72541958a7 100644 --- a/target/riscv/fpu_helper.c +++ b/target/riscv/fpu_helper.c @@ -81,10 +81,16 @@ void helper_set_rounding_mode(CPURISCVState *env, uint32_t rm) set_float_rounding_mode(softrm, &env->fp_status); } +static uint64_t do_fmadd_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2, + uint64_t frs3, int flags) +{ + return nanbox_s(float32_muladd(frs1, frs2, frs3, flags, &env->fp_status)); +} + uint64_t helper_fmadd_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2, uint64_t frs3) { - return float32_muladd(frs1, frs2, frs3, 0, &env->fp_status); + return do_fmadd_s(env, frs1, frs2, frs3, 0); } uint64_t helper_fmadd_d(CPURISCVState *env, uint64_t frs1, uint64_t frs2, @@ -96,8 +102,7 @@ uint64_t helper_fmadd_d(CPURISCVState *env, uint64_t frs1, uint64_t frs2, uint64_t helper_fmsub_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2, uint64_t frs3) { - return float32_muladd(frs1, frs2, frs3, float_muladd_negate_c, - &env->fp_status); + return do_fmadd_s(env, frs1, frs2, frs3, float_muladd_negate_c); } uint64_t helper_fmsub_d(CPURISCVState *env, uint64_t frs1, uint64_t frs2, @@ -110,8 +115,7 @@ uint64_t helper_fmsub_d(CPURISCVState *env, uint64_t frs1, uint64_t frs2, uint64_t helper_fnmsub_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2, uint64_t frs3) { - return float32_muladd(frs1, frs2, frs3, float_muladd_negate_product, - &env->fp_status); + return do_fmadd_s(env, frs1, frs2, frs3, float_muladd_negate_product); } uint64_t helper_fnmsub_d(CPURISCVState *env, uint64_t frs1, uint64_t frs2, @@ -124,8 +128,8 @@ uint64_t helper_fnmsub_d(CPURISCVState *env, uint64_t frs1, uint64_t frs2, uint64_t helper_fnmadd_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2, uint64_t frs3) { - return float32_muladd(frs1, frs2, frs3, float_muladd_negate_c | - float_muladd_negate_product, &env->fp_status); + return do_fmadd_s(env, frs1, frs2, frs3, + float_muladd_negate_c | float_muladd_negate_product); } uint64_t helper_fnmadd_d(CPURISCVState *env, uint64_t frs1, uint64_t frs2, @@ -137,37 +141,37 @@ uint64_t helper_fnmadd_d(CPURISCVState *env, uint64_t frs1, uint64_t frs2, uint64_t helper_fadd_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) { - return float32_add(frs1, frs2, &env->fp_status); + return nanbox_s(float32_add(frs1, frs2, &env->fp_status)); } uint64_t helper_fsub_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) { - return float32_sub(frs1, frs2, &env->fp_status); + return nanbox_s(float32_sub(frs1, frs2, &env->fp_status)); } uint64_t helper_fmul_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) { - return float32_mul(frs1, frs2, &env->fp_status); + return nanbox_s(float32_mul(frs1, frs2, &env->fp_status)); } uint64_t helper_fdiv_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) { - return float32_div(frs1, frs2, &env->fp_status); + return nanbox_s(float32_div(frs1, frs2, &env->fp_status)); } uint64_t helper_fmin_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) { - return float32_minnum(frs1, frs2, &env->fp_status); + return nanbox_s(float32_minnum(frs1, frs2, &env->fp_status)); } uint64_t helper_fmax_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) { - return float32_maxnum(frs1, frs2, &env->fp_status); + return nanbox_s(float32_maxnum(frs1, frs2, &env->fp_status)); } uint64_t helper_fsqrt_s(CPURISCVState *env, uint64_t frs1) { - return float32_sqrt(frs1, &env->fp_status); + return nanbox_s(float32_sqrt(frs1, &env->fp_status)); } target_ulong helper_fle_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) @@ -209,23 +213,23 @@ uint64_t helper_fcvt_lu_s(CPURISCVState *env, uint64_t frs1) uint64_t helper_fcvt_s_w(CPURISCVState *env, target_ulong rs1) { - return int32_to_float32((int32_t)rs1, &env->fp_status); + return nanbox_s(int32_to_float32((int32_t)rs1, &env->fp_status)); } uint64_t helper_fcvt_s_wu(CPURISCVState *env, target_ulong rs1) { - return uint32_to_float32((uint32_t)rs1, &env->fp_status); + return nanbox_s(uint32_to_float32((uint32_t)rs1, &env->fp_status)); } #if defined(TARGET_RISCV64) uint64_t helper_fcvt_s_l(CPURISCVState *env, uint64_t rs1) { - return int64_to_float32(rs1, &env->fp_status); + return nanbox_s(int64_to_float32(rs1, &env->fp_status)); } uint64_t helper_fcvt_s_lu(CPURISCVState *env, uint64_t rs1) { - return uint64_to_float32(rs1, &env->fp_status); + return nanbox_s(uint64_to_float32(rs1, &env->fp_status)); } #endif @@ -266,7 +270,7 @@ uint64_t helper_fmax_d(CPURISCVState *env, uint64_t frs1, uint64_t frs2) uint64_t helper_fcvt_s_d(CPURISCVState *env, uint64_t rs1) { - return float64_to_float32(rs1, &env->fp_status); + return nanbox_s(float64_to_float32(rs1, &env->fp_status)); } uint64_t helper_fcvt_d_s(CPURISCVState *env, uint64_t rs1) From patchwork Wed Aug 12 22:30:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 247644 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp770373ilo; Wed, 12 Aug 2020 15:42:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwEleXBQ48HhmikApNqIlhcQmOUVaaXfO/Caf9Yj3f9tSddWOSKRlpnAki3KIcrBYgZwUT1 X-Received: by 2002:a25:c345:: with SMTP id t66mr2435344ybf.218.1597272162776; Wed, 12 Aug 2020 15:42:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597272162; cv=none; d=google.com; s=arc-20160816; b=vfpdKwVdJIO2w3f0iM58xu6w1dCAdTaW4HSXjPiuSypw2+o0skrgQUOsNH1BiF8HwY vUGmyi4Zuv68lmHimgzDH0Bkub1x0lt4QOUN8XCHfpKOxjBEt+yKdCbQQs6DVTh0Vj64 Q2NzY18o/pHl9VUjGIOqOV5dQp21NHdQaOopd2OE6FdlsHGXWhIftzKWS4i79qO8CcS7 JOS0UkKMSLkiYLfJsJyTYuCKAV4zWE66l9jyU5Tfl45CcxdcAX8DE1COQAoXsCaDkUYw Yd9i9Q+p1fkz4jnrMv7zJ46DM72YR+9q5x6LYYuRzktMm5RgiRbEDkI6u+gYQChJxQ/4 LVDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :wdcironportexception:ironport-sdr:ironport-sdr:ironport-sdr :dkim-signature; bh=r8JEQz2eBqSJ2uXuW09rg/aTRbfvxh0SErI0Y4oFI+w=; b=MLetZAiZEJ9aEacwyWLjb3/7CIePzOuEmsfqghcXhEU+7qXlj7cPhlPvxnP88GUcEO xs41pA+/uu8EnSmbYxgvoZOhLH5WYDHqZ5tw2mlOT8g/1ljZYTiukPEi6hd+gYzuYhhJ ckidjsZO2VDQtgdnVX8tBF36SjZFv3MRochPPqPflTAjveiJkD8w+CAloPHmdKVE5TJN ak3GmJJ44oYCkn6YAQ9AAFyPpX6/aqz7Y4Ay8jEWEuad3C8PSZ2pBC9fnScEqYuzYpnE AlFKARBdmKZWilCE2zsnM0nSO467Wmf/0Sph6QIIAUqXXNZXH4m+h9fvvCcYipB8WnRs pllg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=U7Vsq2Jl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 128si3615062yba.124.2020.08.12.15.42.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Aug 2020 15:42:42 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=U7Vsq2Jl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Received: from localhost ([::1]:34698 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5zSA-0003ay-86 for patch@linaro.org; Wed, 12 Aug 2020 18:42:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39496) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQU-0002H3-T8 for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:40:54 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:56480) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQR-0005oE-G5 for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:40:54 -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=1597272051; x=1628808051; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jL8la5SaUZPFPaXp7NmU6atCG+J2ay2cXyu6f42UdYk=; b=U7Vsq2JlUdP2GEvpWk4Ll1GNZHvN8mhXt6YyZUhVF5yHenJOzKLP567V GfaN4wg2e6r620d8zYwR7xVtsM5nojcFWQQl/Ai16TqM3ybnMsnpk44xY F7hZVfbf01skr0kTCVva2+cXbwKKdfZrErZkZK1Uk+71VlKzyOzGqvC1U ypiesdaxgjd0il2JjjZ6yLR6znsbdFIDFvusHz53PrTNKIClHqyUEjg/A JFPsMEjxD+oyJy4d0vZ/585NNYvKi8+MBaE5mlFYxBJPlynIiHNiScpKL QTSnUqGhRdgI5dNDJDyQSlL5CyAGo8a/0+iu7Q8f7MeJHdtBq7vxGDvKc g==; IronPort-SDR: IHjIddzMoa+1SJF0yKhZ8CqUSecXAy9SuMGtHEobRFtPeUoakoLGPagvK/84GeeCvAXqa7hQ/4 ZpCSXyPfc60I1yLluLRW2te5ecvfzh3ocfzs7Pl/TeOoJwMHeXRmWp8pf1MeNqCcXBuqjcvqFv MQOAOavjboeKUDIU/XtYZArzc8PA5yRaD3nUkPelcQ/yX0ypTe2a0Dk47T+2rUKneTIPa7mt3/ tT1LhQZSCGTNWO34pSF3zdl4uI9Q5/p+TuSmQTp5LdfbK18Trv7v1mP8pZTf8yeQSWFzP7meLI ekY= X-IronPort-AV: E=Sophos;i="5.76,305,1592841600"; d="scan'208";a="144853391" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 13 Aug 2020 06:40:48 +0800 IronPort-SDR: jOg/EHds++OtJwZ3ex23mJ1GzL2XtWPiJZllGk6pqqT4H+Q4OpBNXRPGgxgAX/ld2g7BL6aMPn AynOnvZbmK6w== Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 15:28:38 -0700 IronPort-SDR: rue34bdCbrZGzJ8YLTkWsavkovnKh618O2lgNGaANsLHkNaGB2KByteYN1EudBhmhY7nE8lmAB JRj1CYNO6dHA== WDCIronportException: Internal Received: from jbfyk72.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.59.14]) by uls-op-cesaip01.wdc.com with ESMTP; 12 Aug 2020 15:40:44 -0700 From: Alistair Francis To: qemu-devel@nongnu.org Subject: [PULL 02/20] target/riscv: Generalize gen_nanbox_fpr to gen_nanbox_s Date: Wed, 12 Aug 2020 15:30:27 -0700 Message-Id: <20200812223045.96803-3-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200812223045.96803-1-alistair.francis@wdc.com> References: <20200812223045.96803-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=486123ee4=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/12 18:40:47 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] 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, URIBL_BLOCKED=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: , Cc: Alistair Francis , Richard Henderson , LIU Zhiwei Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Do not depend on the RVD extension, take input and output via TCGv_i64 instead of fpu regno. Move the function to translate.c so that it can be used in multiple trans_*.inc.c files. Signed-off-by: Richard Henderson Reviewed-by: LIU Zhiwei Message-Id: <20200724002807.441147-3-richard.henderson@linaro.org> Signed-off-by: Alistair Francis --- target/riscv/insn_trans/trans_rvf.inc.c | 16 +--------------- target/riscv/translate.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 15 deletions(-) -- 2.27.0 diff --git a/target/riscv/insn_trans/trans_rvf.inc.c b/target/riscv/insn_trans/trans_rvf.inc.c index 3bfd8881e7..c7057482e8 100644 --- a/target/riscv/insn_trans/trans_rvf.inc.c +++ b/target/riscv/insn_trans/trans_rvf.inc.c @@ -23,20 +23,6 @@ return false; \ } while (0) -/* - * RISC-V requires NaN-boxing of narrower width floating - * point values. This applies when a 32-bit value is - * assigned to a 64-bit FP register. Thus this does not - * apply when the RVD extension is not present. - */ -static void gen_nanbox_fpr(DisasContext *ctx, int regno) -{ - if (has_ext(ctx, RVD)) { - tcg_gen_ori_i64(cpu_fpr[regno], cpu_fpr[regno], - MAKE_64BIT_MASK(32, 32)); - } -} - static bool trans_flw(DisasContext *ctx, arg_flw *a) { TCGv t0 = tcg_temp_new(); @@ -46,7 +32,7 @@ static bool trans_flw(DisasContext *ctx, arg_flw *a) tcg_gen_addi_tl(t0, t0, a->imm); tcg_gen_qemu_ld_i64(cpu_fpr[a->rd], t0, ctx->mem_idx, MO_TEUL); - gen_nanbox_fpr(ctx, a->rd); + gen_nanbox_s(cpu_fpr[a->rd], cpu_fpr[a->rd]); tcg_temp_free(t0); mark_fs_dirty(ctx); diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 9632e79cf3..12a746da97 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -90,6 +90,17 @@ static inline bool has_ext(DisasContext *ctx, uint32_t ext) return ctx->misa & ext; } +/* + * RISC-V requires NaN-boxing of narrower width floating point values. + * This applies when a 32-bit value is assigned to a 64-bit FP register. + * For consistency and simplicity, we nanbox results even when the RVD + * extension is not present. + */ +static void gen_nanbox_s(TCGv_i64 out, TCGv_i64 in) +{ + tcg_gen_ori_i64(out, in, MAKE_64BIT_MASK(32, 32)); +} + static void generate_exception(DisasContext *ctx, int excp) { tcg_gen_movi_tl(cpu_pc, ctx->base.pc_next); From patchwork Wed Aug 12 22:30:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 247645 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp770752ilo; Wed, 12 Aug 2020 15:43:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyb5cCc0lmU4hlSeGfeC51hFKR5FNsDjdCoZc1UQAbTwexVNczkGBvRA4Hb2N6fqI96FS2M X-Received: by 2002:a5b:451:: with SMTP id s17mr2413725ybp.454.1597272205369; Wed, 12 Aug 2020 15:43:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597272205; cv=none; d=google.com; s=arc-20160816; b=dZ/2BuG9KKpJNGd89w9Hp6ZpAfbUGb170X2xN3+wVhYq3YMN8KMXZrvSUzQVE1uWws mduPK8uzLy/C5M9nNlmacBzeCmXZRuF6680PaEakxithFCObgWM6LhpX0PFqniUoS5cK AskckvUe1GcFM6Rz8WJ56TDguSz8g85wZ5ipl7i3S4oeFtDGvQmKjlw5Hn+8JTHsTvqV t+cGmEuJd0QM2Gf6HA9jCkaozchgTiaK4X0dtOvDRllnk41mLyH3Y/+9VRhzaZcI69qH MSNLjwTLQw/FZ9soDo9i87HR+zCYGCL0oI9qJD0C7kfHgdL2ztcaT5hc9242wmaNqDek xVdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :wdcironportexception:ironport-sdr:ironport-sdr:ironport-sdr :dkim-signature; bh=UDQK50NAjBzFJ7lcQTIagVmUKR0TS++M5gseWdybAck=; b=zjVObpWkMBV5+RqM3xJhf9M0XqCPFHBEbyd+/EbHsIaNOy6BXz5//ep1kRdyuCfax6 GqHfoxD8wxVvEwBPFoMXHwsd/jn3VMPcNxGGckkLJJl92Z4tWubEWjJ8njhrMXcnO/aW Gq8/uRlOD0gd6RGyRN4YtTrL6zLUfyLXCy/BnLl996g7/Wv0CdzW5dARuhbCbSEXpq9A F+PY3IX0WvQoTDo3ys1etAnllHeAGrecrMnCspvMQXbkdsoZaDwecuYvSdSOyNBSo/xM i7OaHSh2zZpgAjQEI21StQyfM9vwMRwKFRSFdIU8bt9cMA+3Ulk2t8B5S4CK/JNVXF/Y MWgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b="F/ccqATw"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y13si3562706ybe.485.2020.08.12.15.43.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Aug 2020 15:43:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b="F/ccqATw"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Received: from localhost ([::1]:40102 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5zSu-0005l8-Or for patch@linaro.org; Wed, 12 Aug 2020 18:43:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39462) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQU-0002GK-7j for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:40:54 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:29819) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQQ-0005m7-Np for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:40:53 -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=1597272050; x=1628808050; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uOT7bF66BUjn23EePzsUiUnjjzNFLMEUpDfYHK1C+rg=; b=F/ccqATwhWJEyQ/wg5BFY9FHc0SmxLNC1Shd+4Om5INZALXpMezjdjmo fJ7cbQI2sxPFIUF0vvS6+GnfhbCAX2UATO0YppjwzOb7C86iR6Fs9Fbhw GEPfy9YvOmuJ0nCLLYZVtbnH3riZIAnBzml+bcobhM5DFG2wAiyBHDYMw TqtKNuLOzFD5jSEusbMWlrfzMrJDeTdBu4nWLrTEZADw4Gzj7vMftOarK gtN3C9H/XryOv8a8kausdI8jmNDB106g4kXk7mFbNebjyvzSTuvBoUCwt 9OQ+Au8vFh7Kk9RqGoEK0oXLRzA5B2/bh+f2vT2PLNNWwopm8JiEo1MLe Q==; IronPort-SDR: hgYeQVsk4jfohyigAs01ncZjYdW9fmRYMKJZdHlHLV8p2hKJC0QO6CKcofVCbcBVNPEIY2ZbO3 imKtOUz+sI0Vt815RQ/mFaR4Q0iOaTNSp7ess/Pn0+kQqtm2mOj8ANJE+Icbd9tp5lu+iOayBM zuNFyl6dZRyKEYtPtdMPJMHkzbIQxI2jiq4kMvBZwIfXa3sDqAVwypezp4wZPojhD/sY2+mchx jCamXZrhOnLhosQdnfS3FAruemsagC7wpg3EKndhnYN18AUBxE3Zi5VZpaxBh9a3Z/4vsHmJ7O 610= X-IronPort-AV: E=Sophos;i="5.76,305,1592841600"; d="scan'208";a="254208922" 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; 13 Aug 2020 06:40:47 +0800 IronPort-SDR: w+ELM2D+PDdDKIKRqp3ykx1b/zlqY5p0WceomGbPD3YWrAOIoF8pwreN4pIgZK/QQxIUhGekIv 9Tu+0hHXXzWA== Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 15:27:56 -0700 IronPort-SDR: kewG0wE1NH5JgO6m9hrcMUvTeb2A3JK6NgnAIBB4dKf83y4fG4JORDMVvB6J8u6ZTSo0M8PwSj tKlDTuEGhsRA== WDCIronportException: Internal Received: from jbfyk72.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.59.14]) by uls-op-cesaip01.wdc.com with ESMTP; 12 Aug 2020 15:40:45 -0700 From: Alistair Francis To: qemu-devel@nongnu.org Subject: [PULL 03/20] target/riscv: Generate nanboxed results from trans_rvf.inc.c Date: Wed, 12 Aug 2020 15:30:28 -0700 Message-Id: <20200812223045.96803-4-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200812223045.96803-1-alistair.francis@wdc.com> References: <20200812223045.96803-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=68.232.141.245; envelope-from=prvs=486123ee4=alistair.francis@wdc.com; helo=esa1.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/12 18:40:48 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] 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, URIBL_BLOCKED=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: , Cc: Alistair Francis , Richard Henderson , LIU Zhiwei Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Make sure that all results from inline single-precision scalar operations are properly nan-boxed to 64-bits. Signed-off-by: Richard Henderson Reviewed-by: LIU Zhiwei Message-Id: <20200724002807.441147-4-richard.henderson@linaro.org> Signed-off-by: Alistair Francis --- target/riscv/insn_trans/trans_rvf.inc.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.27.0 diff --git a/target/riscv/insn_trans/trans_rvf.inc.c b/target/riscv/insn_trans/trans_rvf.inc.c index c7057482e8..264d3139f1 100644 --- a/target/riscv/insn_trans/trans_rvf.inc.c +++ b/target/riscv/insn_trans/trans_rvf.inc.c @@ -167,6 +167,7 @@ static bool trans_fsgnj_s(DisasContext *ctx, arg_fsgnj_s *a) tcg_gen_deposit_i64(cpu_fpr[a->rd], cpu_fpr[a->rs2], cpu_fpr[a->rs1], 0, 31); } + gen_nanbox_s(cpu_fpr[a->rd], cpu_fpr[a->rd]); mark_fs_dirty(ctx); return true; } @@ -183,6 +184,7 @@ static bool trans_fsgnjn_s(DisasContext *ctx, arg_fsgnjn_s *a) tcg_gen_deposit_i64(cpu_fpr[a->rd], t0, cpu_fpr[a->rs1], 0, 31); tcg_temp_free_i64(t0); } + gen_nanbox_s(cpu_fpr[a->rd], cpu_fpr[a->rd]); mark_fs_dirty(ctx); return true; } @@ -199,6 +201,7 @@ static bool trans_fsgnjx_s(DisasContext *ctx, arg_fsgnjx_s *a) tcg_gen_xor_i64(cpu_fpr[a->rd], cpu_fpr[a->rs1], t0); tcg_temp_free_i64(t0); } + gen_nanbox_s(cpu_fpr[a->rd], cpu_fpr[a->rd]); mark_fs_dirty(ctx); return true; } @@ -369,6 +372,7 @@ static bool trans_fmv_w_x(DisasContext *ctx, arg_fmv_w_x *a) #else tcg_gen_extu_i32_i64(cpu_fpr[a->rd], t0); #endif + gen_nanbox_s(cpu_fpr[a->rd], cpu_fpr[a->rd]); mark_fs_dirty(ctx); tcg_temp_free(t0); From patchwork Wed Aug 12 22:30:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 247647 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp771662ilo; Wed, 12 Aug 2020 15:45:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJ2x7eMas1nnZqbbxUMWnAppOjP1QxSRzssz3wCNKRXsVpmQw6+EYjdpkGDIW+upam9DLk X-Received: by 2002:a25:860d:: with SMTP id y13mr2231085ybk.479.1597272307998; Wed, 12 Aug 2020 15:45:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597272307; cv=none; d=google.com; s=arc-20160816; b=Mkc6t0oma9YlkUgWpIng5BRgrSu2Qrvp3HBObtDtF5DoM/Mcabm/CjUoPsz6bDzyir bzFjUHDtb5NGxl31Nllg4rCK1KIBAD1uvU09BRtCYJ/tOGqO2OPHAlTWD47S57FxkeG3 cQSUXmFz4Yng8uJGZWhwLvkK7i5DKz8xPPnjuZQT9UfeBQyuCY78yWpca77yftjobrR9 PKXWC4onJeXl0bXW+bK7ZMVM0qGeK5KJmk8wE1L4YAwH1fnLf5CYD5fTnLJ0cFA7wChT M9tU9coKu/GNNOvyjJuObBK1hjFj7Z7YKqyrZ/myQZjTYN24IdKRfvYjQjUFSIZiYOXt HA+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :wdcironportexception:ironport-sdr:ironport-sdr:ironport-sdr :dkim-signature; bh=BZHgC/oyhSXdNx+U3mEurTd4bg77NtIKj22CXqeBCXU=; b=X4K8iIU+o7wCaAMi/4HwuSi4gB0jvU3K8660gFc0Cz2R8gULyyoM6mEUb9bAaw40xn p5WVKL5vDbbnrK9N5jS6Aiyj5pXlLxzes0MsNL68QHsOu6gnQ+okAKv+vzEA4lfB3XwB HBAlBXlylOpIJMdFbJwoa4XR90ipuPhS/uR4EcTpRvVQ35SVW9T4qJhALIUS6KMxIN2e 6TUjm3rUusWR7qbei2OhlVoH6QSa6zQGGLuJBUb1i9tjzH+rC7yn1gKcRcQBxNPPvDhW bw9jiMX014r9iME9ZLeTQ2Euxx8cRflYeaUWccobcEJHQ0ztCxPOA9Wt0If/+uGDZ9gd n/yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=iEVIbjP+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o17si3737616ybc.291.2020.08.12.15.45.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Aug 2020 15:45:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=iEVIbjP+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Received: from localhost ([::1]:48734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5zUZ-0000k2-Cc for patch@linaro.org; Wed, 12 Aug 2020 18:45:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39516) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQV-0002HV-Cs for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:40:55 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:56476) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQT-0005lp-Bi for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:40:55 -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=1597272053; x=1628808053; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2uxc3mgF5IfdNIUdAxumFcq0huRtRLtJ8AaE/KG/tlI=; b=iEVIbjP+shTWlXCY6MG9biTRdzyCfx87EiM0ZrAa34ngdX4KQqal4aYh RiTvBV1+ENTwgvFYg9AQLCLTH1O+9Yw4jhl7WI3UCIiWqQxpMGFjQORFg ZMP5+py01Ocb6LFPNUC38qU45hix2Zd2q5R/2Pc2rSv5yNCe9X1NXMrcL i0tidUP5rVEAnlUYco0LNoR3M2lqwkoFm3Mbt0Oglz8I5R8DKkTjiJqld ZnYQGCFcmtiIlWAMVwJ7ZmRsw2thFT5ZzOwzVg8pmfWMMb00jQfwWT8yB GXW31bvlPfUviEC5suVdsWLstkyKvBkvtihw/oteBRKo5hrAYEZnSVgCa Q==; IronPort-SDR: olnGD2aMzfJ13Xuv5NrlYK4O1I1X6MYGo7Xtuhli1Q593fOEXDMbu0VKEYqKVVPr3a74SfntU5 6Nq1c0FHES2fhoVZVStpxPAebXLZ84jdtuDSe0KN2dd/MEXEy56B83yhCK4Qk/HPouWrfTd56/ 97qS9tVuRXe0yosJ0kEoRfAzPk1T9s4ANas8ueIty/nHgUPJHZjhMbnheMqmWT3iE0eZHWI8h7 VBwjMc+fPifZmh6fiMhfEwp+eyx9fieFPyIQSNQjucdpUCswWfL3D8vtHbYVx4Nky4Fa2/7Xxd dQQ= X-IronPort-AV: E=Sophos;i="5.76,305,1592841600"; d="scan'208";a="144853392" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 13 Aug 2020 06:40:48 +0800 IronPort-SDR: h0/DA1k1cxFQxidcjGALa8qaO4/nDmNkHmBlYjATnyA4pUmT/9gcwdxvbkgRq6k9t+zv/XMJ0k Bwkvgsm7xzwA== Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 15:28:39 -0700 IronPort-SDR: EA9DnRyBVp9lkVY5dRSkpmPqHsvhbhxzMB7QGfF1K6NB0IZasYf3umhrMSlQkMnZ2oyZ46IWCM KsfT9cEzBSdA== WDCIronportException: Internal Received: from jbfyk72.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.59.14]) by uls-op-cesaip01.wdc.com with ESMTP; 12 Aug 2020 15:40:45 -0700 From: Alistair Francis To: qemu-devel@nongnu.org Subject: [PULL 04/20] target/riscv: Check nanboxed inputs to fp helpers Date: Wed, 12 Aug 2020 15:30:29 -0700 Message-Id: <20200812223045.96803-5-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200812223045.96803-1-alistair.francis@wdc.com> References: <20200812223045.96803-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=486123ee4=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/12 18:40:47 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] 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, URIBL_BLOCKED=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: , Cc: Alistair Francis , Richard Henderson , LIU Zhiwei Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson If a 32-bit input is not properly nanboxed, then the input is replaced with the default qnan. Signed-off-by: Richard Henderson Reviewed-by: LIU Zhiwei Message-Id: <20200724002807.441147-5-richard.henderson@linaro.org> Signed-off-by: Alistair Francis --- target/riscv/internals.h | 11 +++++++ target/riscv/fpu_helper.c | 64 ++++++++++++++++++++++++++++----------- 2 files changed, 57 insertions(+), 18 deletions(-) -- 2.27.0 diff --git a/target/riscv/internals.h b/target/riscv/internals.h index 9f4ba7d617..f1a546dba6 100644 --- a/target/riscv/internals.h +++ b/target/riscv/internals.h @@ -43,4 +43,15 @@ static inline uint64_t nanbox_s(float32 f) return f | MAKE_64BIT_MASK(32, 32); } +static inline float32 check_nanbox_s(uint64_t f) +{ + uint64_t mask = MAKE_64BIT_MASK(32, 32); + + if (likely((f & mask) == mask)) { + return (uint32_t)f; + } else { + return 0x7fc00000u; /* default qnan */ + } +} + #endif diff --git a/target/riscv/fpu_helper.c b/target/riscv/fpu_helper.c index 72541958a7..bb346a8249 100644 --- a/target/riscv/fpu_helper.c +++ b/target/riscv/fpu_helper.c @@ -81,9 +81,12 @@ void helper_set_rounding_mode(CPURISCVState *env, uint32_t rm) set_float_rounding_mode(softrm, &env->fp_status); } -static uint64_t do_fmadd_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2, - uint64_t frs3, int flags) +static uint64_t do_fmadd_s(CPURISCVState *env, uint64_t rs1, uint64_t rs2, + uint64_t rs3, int flags) { + float32 frs1 = check_nanbox_s(rs1); + float32 frs2 = check_nanbox_s(rs2); + float32 frs3 = check_nanbox_s(rs3); return nanbox_s(float32_muladd(frs1, frs2, frs3, flags, &env->fp_status)); } @@ -139,74 +142,97 @@ uint64_t helper_fnmadd_d(CPURISCVState *env, uint64_t frs1, uint64_t frs2, float_muladd_negate_product, &env->fp_status); } -uint64_t helper_fadd_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) +uint64_t helper_fadd_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_add(frs1, frs2, &env->fp_status)); } -uint64_t helper_fsub_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) +uint64_t helper_fsub_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_sub(frs1, frs2, &env->fp_status)); } -uint64_t helper_fmul_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) +uint64_t helper_fmul_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_mul(frs1, frs2, &env->fp_status)); } -uint64_t helper_fdiv_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) +uint64_t helper_fdiv_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_div(frs1, frs2, &env->fp_status)); } -uint64_t helper_fmin_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) +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)); } -uint64_t helper_fmax_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) +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)); } -uint64_t helper_fsqrt_s(CPURISCVState *env, uint64_t frs1) +uint64_t helper_fsqrt_s(CPURISCVState *env, uint64_t rs1) { + float32 frs1 = check_nanbox_s(rs1); return nanbox_s(float32_sqrt(frs1, &env->fp_status)); } -target_ulong helper_fle_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) +target_ulong helper_fle_s(CPURISCVState *env, uint64_t rs1, uint64_t rs2) { + float32 frs1 = check_nanbox_s(rs1); + float32 frs2 = check_nanbox_s(rs2); return float32_le(frs1, frs2, &env->fp_status); } -target_ulong helper_flt_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) +target_ulong helper_flt_s(CPURISCVState *env, uint64_t rs1, uint64_t rs2) { + float32 frs1 = check_nanbox_s(rs1); + float32 frs2 = check_nanbox_s(rs2); return float32_lt(frs1, frs2, &env->fp_status); } -target_ulong helper_feq_s(CPURISCVState *env, uint64_t frs1, uint64_t frs2) +target_ulong helper_feq_s(CPURISCVState *env, uint64_t rs1, uint64_t rs2) { + float32 frs1 = check_nanbox_s(rs1); + float32 frs2 = check_nanbox_s(rs2); return float32_eq_quiet(frs1, frs2, &env->fp_status); } -target_ulong helper_fcvt_w_s(CPURISCVState *env, uint64_t frs1) +target_ulong helper_fcvt_w_s(CPURISCVState *env, uint64_t rs1) { + float32 frs1 = check_nanbox_s(rs1); return float32_to_int32(frs1, &env->fp_status); } -target_ulong helper_fcvt_wu_s(CPURISCVState *env, uint64_t frs1) +target_ulong helper_fcvt_wu_s(CPURISCVState *env, uint64_t rs1) { + float32 frs1 = check_nanbox_s(rs1); return (int32_t)float32_to_uint32(frs1, &env->fp_status); } #if defined(TARGET_RISCV64) -uint64_t helper_fcvt_l_s(CPURISCVState *env, uint64_t frs1) +uint64_t helper_fcvt_l_s(CPURISCVState *env, uint64_t rs1) { + float32 frs1 = check_nanbox_s(rs1); return float32_to_int64(frs1, &env->fp_status); } -uint64_t helper_fcvt_lu_s(CPURISCVState *env, uint64_t frs1) +uint64_t helper_fcvt_lu_s(CPURISCVState *env, uint64_t rs1) { + float32 frs1 = check_nanbox_s(rs1); return float32_to_uint64(frs1, &env->fp_status); } #endif @@ -233,8 +259,9 @@ uint64_t helper_fcvt_s_lu(CPURISCVState *env, uint64_t rs1) } #endif -target_ulong helper_fclass_s(uint64_t frs1) +target_ulong helper_fclass_s(uint64_t rs1) { + float32 frs1 = check_nanbox_s(rs1); return fclass_s(frs1); } @@ -275,7 +302,8 @@ uint64_t helper_fcvt_s_d(CPURISCVState *env, uint64_t rs1) uint64_t helper_fcvt_d_s(CPURISCVState *env, uint64_t rs1) { - return float32_to_float64(rs1, &env->fp_status); + float32 frs1 = check_nanbox_s(rs1); + return float32_to_float64(frs1, &env->fp_status); } uint64_t helper_fsqrt_d(CPURISCVState *env, uint64_t frs1) From patchwork Wed Aug 12 22:30:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 247643 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp769848ilo; Wed, 12 Aug 2020 15:41:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQmiC0hxECU2SiudwwrPSlD41Amdj97cICwAYpy91GNwsOi9HShEkzCxyNPGE08Z+yVqy/ X-Received: by 2002:a05:6902:52d:: with SMTP id y13mr2578137ybs.144.1597272109922; Wed, 12 Aug 2020 15:41:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597272109; cv=none; d=google.com; s=arc-20160816; b=b/KB9DPh3X/hjNYesrtiJ6K8Yb7pdBpLo5VeVRQCRu+8ZLUyg0VnWOESyKYvuLEeA5 miLo0dIabI/0wDljs847wUcvLKj9rPy656T/ngXqjyVK4WH8Lh2silnlhBaOmtsJyM1Z 7kF7/TCNQXaSxNjvnInbC99P0PDhTjCdlkJGjI30a89KWgUd0Y7pSpL6/ssZyHGg574T ghNxqBssibH0i81Ev09cq1JuBhGTGbv6Iim2x9h9udrzNWvdaMphRFNUhmXuRYqujY/W D7BHjEEgKKXlINwNamToF+goD22oDZyaj4BH/b3sEcpvbZj8ytma5EFG8bouqpOBGLvf I/0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :wdcironportexception:ironport-sdr:ironport-sdr:ironport-sdr :dkim-signature; bh=UhV/di5HKbltGlqa9gOqRbdv3WZSIsAv+1vtkbvSNWE=; b=h6bTiztRLiWL5vJl8WvKHVfTysfVbmyJ0ZedasGk1WbxNq7yDT8nXPRT+wVCUXiJSz KJKQmSz2kB/5UF3U6+yvS5YPWxCyyyiVSDYbGDrnZyZJsleVu5Kns3TiBYOQTJNOrUmi 5zGyJveiLOOd/54ftZ1cHVpbe8Dg+/kM7qUj+QzyAXzD9ej7b/4v9YP1aRlNLD+HudUO pHjQxNF8U4nGncfTQt0ujks/s8XIp3cPcyNm0qeON/qkpPdaBIJyh2dXl8rkaX4drmQU fHA7k5VlYAwn9nFBzWCtTsYtg6an2ece++97P20GyxoaWhTcLWZnC7HS8GYO+ca5AY38 6XuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=n4Qy0ilD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v13si3420529ybm.444.2020.08.12.15.41.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Aug 2020 15:41:49 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=n4Qy0ilD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Received: from localhost ([::1]:59836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5zRN-0002Hm-CP for patch@linaro.org; Wed, 12 Aug 2020 18:41:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39452) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQT-0002GC-Se for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:40:53 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:29822) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQR-0005nU-8v for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:40:53 -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=1597272051; x=1628808051; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0hinW4AOS9dVAXrUyO3aCuRIqVjkZ84Vja4z9gCfEqI=; b=n4Qy0ilD8ycfkLc4NLt9wqqmgtulRLobs7RUKwMpHrLjThZYAHknnI4h mgRuX17DiMrqQxAQGW6Rj+vTj20mLODSKGCm5zKhowc8y3rPz/xB/naQC cfiE1dyARPbSanh497JATGyvWR1+LhZiHHjkqullmlI9m5sh17YyQ5XVU RIu3CUr+fwz9gAzi2gK89e+rrJ3DKqnhoC0Zn9YF2+g8G9ZaAFDeOVKTI FwcIeObpT2zybNxx47Q+r3nUnDpoF0iew6WEgsO6UzqulQ/co2l80zXd8 lhEf2s90KS0DkmE1TsgEmbVnmdX2Oox1ZeWZAl+H3Bbi5pYKmDJ7KD7oo w==; IronPort-SDR: VH6Ni0wrUvwvu82f7uyaLHw8bVdqcuQDkK0v+quKazAYNsdWtrIlZhY1RXs9IvSoiQyvd2amJJ JzQH1r3Oh7zq78bfNlyHEelde01baTSyk6hZEh07BN9y1y3P67WYudHmfoxMWzs5hzO+NSX9WR l6GeoaT209wdnqvqm89Edd48VCKmfWmnGKQsY6fTg7mBx0tKqain5n9DWp7y+wID6q+Mr4edmP aEuOEwym6i4HMglDSvWpwLvk3mQMnemftzv+DM9b70WP+2HZGVfxfT3c2hlH4YM/L8fcUJ6uhX SKA= X-IronPort-AV: E=Sophos;i="5.76,305,1592841600"; d="scan'208";a="254208925" 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; 13 Aug 2020 06:40:48 +0800 IronPort-SDR: jBU6wrqB5pfwiML5zGi2y61hv5MxgcX2y4FHIz3+D56PnuIOhpPZebLOeTRESPSCwpTf8nfwOU On1yg8b3HS5A== Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 15:27:56 -0700 IronPort-SDR: 6a2e7DP39UqrkmNW31tE8KU93iV7b2XzZkgSvFld5Xi8pUiEX6zcDzOoqMmMJTaFtF91iojoVN nZvui5MowPoA== WDCIronportException: Internal Received: from jbfyk72.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.59.14]) by uls-op-cesaip01.wdc.com with ESMTP; 12 Aug 2020 15:40:45 -0700 From: Alistair Francis To: qemu-devel@nongnu.org Subject: [PULL 05/20] target/riscv: Check nanboxed inputs in trans_rvf.inc.c Date: Wed, 12 Aug 2020 15:30:30 -0700 Message-Id: <20200812223045.96803-6-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200812223045.96803-1-alistair.francis@wdc.com> References: <20200812223045.96803-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=68.232.141.245; envelope-from=prvs=486123ee4=alistair.francis@wdc.com; helo=esa1.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/12 18:40:48 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] 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, URIBL_BLOCKED=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: , Cc: Alistair Francis , Richard Henderson , LIU Zhiwei Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson If a 32-bit input is not properly nanboxed, then the input is replaced with the default qnan. The only inline expansion is for the sign-changing set of instructions: FSGNJ.S, FSGNJX.S, FSGNJN.S. Signed-off-by: Richard Henderson Reviewed-by: LIU Zhiwei Message-Id: <20200724002807.441147-6-richard.henderson@linaro.org> Signed-off-by: Alistair Francis --- target/riscv/insn_trans/trans_rvf.inc.c | 71 +++++++++++++++++++------ target/riscv/translate.c | 18 +++++++ 2 files changed, 73 insertions(+), 16 deletions(-) -- 2.27.0 diff --git a/target/riscv/insn_trans/trans_rvf.inc.c b/target/riscv/insn_trans/trans_rvf.inc.c index 264d3139f1..f9a9e0643a 100644 --- a/target/riscv/insn_trans/trans_rvf.inc.c +++ b/target/riscv/insn_trans/trans_rvf.inc.c @@ -161,47 +161,86 @@ static bool trans_fsgnj_s(DisasContext *ctx, arg_fsgnj_s *a) { REQUIRE_FPU; REQUIRE_EXT(ctx, RVF); + if (a->rs1 == a->rs2) { /* FMOV */ - tcg_gen_mov_i64(cpu_fpr[a->rd], cpu_fpr[a->rs1]); + gen_check_nanbox_s(cpu_fpr[a->rd], cpu_fpr[a->rs1]); } else { /* FSGNJ */ - tcg_gen_deposit_i64(cpu_fpr[a->rd], cpu_fpr[a->rs2], cpu_fpr[a->rs1], - 0, 31); + TCGv_i64 rs1 = tcg_temp_new_i64(); + TCGv_i64 rs2 = tcg_temp_new_i64(); + + gen_check_nanbox_s(rs1, cpu_fpr[a->rs1]); + gen_check_nanbox_s(rs2, cpu_fpr[a->rs2]); + + /* This formulation retains the nanboxing of rs2. */ + tcg_gen_deposit_i64(cpu_fpr[a->rd], rs2, rs1, 0, 31); + tcg_temp_free_i64(rs1); + tcg_temp_free_i64(rs2); } - gen_nanbox_s(cpu_fpr[a->rd], cpu_fpr[a->rd]); mark_fs_dirty(ctx); return true; } static bool trans_fsgnjn_s(DisasContext *ctx, arg_fsgnjn_s *a) { + TCGv_i64 rs1, rs2, mask; + REQUIRE_FPU; REQUIRE_EXT(ctx, RVF); + + rs1 = tcg_temp_new_i64(); + gen_check_nanbox_s(rs1, cpu_fpr[a->rs1]); + if (a->rs1 == a->rs2) { /* FNEG */ - tcg_gen_xori_i64(cpu_fpr[a->rd], cpu_fpr[a->rs1], INT32_MIN); + tcg_gen_xori_i64(cpu_fpr[a->rd], rs1, MAKE_64BIT_MASK(31, 1)); } else { - TCGv_i64 t0 = tcg_temp_new_i64(); - tcg_gen_not_i64(t0, cpu_fpr[a->rs2]); - tcg_gen_deposit_i64(cpu_fpr[a->rd], t0, cpu_fpr[a->rs1], 0, 31); - tcg_temp_free_i64(t0); + rs2 = tcg_temp_new_i64(); + gen_check_nanbox_s(rs2, cpu_fpr[a->rs2]); + + /* + * Replace bit 31 in rs1 with inverse in rs2. + * This formulation retains the nanboxing of rs1. + */ + mask = tcg_const_i64(~MAKE_64BIT_MASK(31, 1)); + tcg_gen_andc_i64(rs2, mask, rs2); + tcg_gen_and_i64(rs1, mask, rs1); + tcg_gen_or_i64(cpu_fpr[a->rd], rs1, rs2); + + tcg_temp_free_i64(mask); + tcg_temp_free_i64(rs2); } - gen_nanbox_s(cpu_fpr[a->rd], cpu_fpr[a->rd]); + tcg_temp_free_i64(rs1); + mark_fs_dirty(ctx); return true; } static bool trans_fsgnjx_s(DisasContext *ctx, arg_fsgnjx_s *a) { + TCGv_i64 rs1, rs2; + REQUIRE_FPU; REQUIRE_EXT(ctx, RVF); + + rs1 = tcg_temp_new_i64(); + gen_check_nanbox_s(rs1, cpu_fpr[a->rs1]); + if (a->rs1 == a->rs2) { /* FABS */ - tcg_gen_andi_i64(cpu_fpr[a->rd], cpu_fpr[a->rs1], ~INT32_MIN); + tcg_gen_andi_i64(cpu_fpr[a->rd], rs1, ~MAKE_64BIT_MASK(31, 1)); } else { - TCGv_i64 t0 = tcg_temp_new_i64(); - tcg_gen_andi_i64(t0, cpu_fpr[a->rs2], INT32_MIN); - tcg_gen_xor_i64(cpu_fpr[a->rd], cpu_fpr[a->rs1], t0); - tcg_temp_free_i64(t0); + rs2 = tcg_temp_new_i64(); + gen_check_nanbox_s(rs2, cpu_fpr[a->rs2]); + + /* + * Xor bit 31 in rs1 with that in rs2. + * This formulation retains the nanboxing of rs1. + */ + tcg_gen_andi_i64(rs2, rs2, MAKE_64BIT_MASK(31, 1)); + tcg_gen_xor_i64(cpu_fpr[a->rd], rs1, rs2); + + tcg_temp_free_i64(rs2); } - gen_nanbox_s(cpu_fpr[a->rd], cpu_fpr[a->rd]); + tcg_temp_free_i64(rs1); + mark_fs_dirty(ctx); return true; } diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 12a746da97..bf35182776 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -101,6 +101,24 @@ static void gen_nanbox_s(TCGv_i64 out, TCGv_i64 in) tcg_gen_ori_i64(out, in, MAKE_64BIT_MASK(32, 32)); } +/* + * A narrow n-bit operation, where n < FLEN, checks that input operands + * are correctly Nan-boxed, i.e., all upper FLEN - n bits are 1. + * If so, the least-significant bits of the input are used, otherwise the + * input value is treated as an n-bit canonical NaN (v2.2 section 9.2). + * + * Here, the result is always nan-boxed, even the canonical nan. + */ +static void gen_check_nanbox_s(TCGv_i64 out, TCGv_i64 in) +{ + TCGv_i64 t_max = tcg_const_i64(0xffffffff00000000ull); + TCGv_i64 t_nan = tcg_const_i64(0xffffffff7fc00000ull); + + tcg_gen_movcond_i64(TCG_COND_GEU, out, in, t_max, in, t_nan); + tcg_temp_free_i64(t_max); + tcg_temp_free_i64(t_nan); +} + static void generate_exception(DisasContext *ctx, int excp) { tcg_gen_movi_tl(cpu_pc, ctx->base.pc_next); From patchwork Wed Aug 12 22:30:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 276652 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A47CBC433E0 for ; Wed, 12 Aug 2020 22:46:08 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6B79E20771 for ; Wed, 12 Aug 2020 22:46:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="Iw3MkyTW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6B79E20771 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:52412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5zVX-0002JZ-IE for qemu-devel@archiver.kernel.org; Wed, 12 Aug 2020 18:46:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39554) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQW-0002Im-5P for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:40:56 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:29822) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQU-0005nU-6C for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:40:55 -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=1597272053; x=1628808053; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+7HheV/vsUAjq9/L+MI1eALkSfh8Qj8GNhvxVKV1NM4=; b=Iw3MkyTWMPy5Ms/RM1ZY3dVG0zqjhwN2EGWTwe38CIHLk3v7KMtOnCug uhbF6wik2gSsUBQbMSG2791Z8A4yhRHbOnOHyFPQkvFEg4X0Bs5df6AHL J1ylJW0FErra7iYKEmeAVSbYOfGBWe6CyrWwLtAdgGyXC7qzQSBcWpaTj O4J4FFYGpha2h7qdFFKLF1P37rhA9xaLE/1ARzoZvYoo9Oqx/oYLP+THi +xR3gjXxUlzuWY1Hp6TZKWEWPoyNMIVrQ41Ws0Eq1XgcXRyr3WRPaMPe6 YI943oRO6I2XPZm7YyxSW9Wj0W+yw04fYJd7K+bh1IG52BC/iIHTmRgKt g==; IronPort-SDR: CR6yVkWh6Q9PIhaHWiA6SP6/oO7WPnmEPCbiFYKki7Q8SY7qUad5aIjg3C4ZScTKxGfqXHZ8+S +4xCITNt+ZDsBkcXvFyFWif3wDCRRZPj9LhrsFdgL9Ujp0f+h8hum2iMXD95Tdb6spaY7yJWeJ Egz5TFtY8L4WuUMoAiyh8stt6DHgOjlBTMR0s+9GB0D8NqY0PmUJekRUiIeWo+JQVFqLvDf/GA zUNyXWHAraD0NyKu0d5WgBNZpFFRUr+R4zBmuSctE7visN+IHZXcwOQUyVCYAfQYho6AidNAvK +/8= X-IronPort-AV: E=Sophos;i="5.76,305,1592841600"; d="scan'208";a="254208929" 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; 13 Aug 2020 06:40:48 +0800 IronPort-SDR: 5sj783Nw9vaWbN8/jWjzhRXzKxyTkSNgeXB8LaopAJn1SNKszTgr2X7e5zTYBlEFVhsIinSnaq jTiL4vmDXjug== Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 15:27:57 -0700 IronPort-SDR: t/Xqrr41H+n8R8KOPZu7l41UdYcKV2tGyhIsdMklZadd4fbL9uSMlxljMqG2pld64T2frWxIvx dqkk4kTmPHow== WDCIronportException: Internal Received: from jbfyk72.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.59.14]) by uls-op-cesaip01.wdc.com with ESMTP; 12 Aug 2020 15:40:46 -0700 From: Alistair Francis To: qemu-devel@nongnu.org Subject: [PULL 07/20] target/riscv: check before allocating TCG temps Date: Wed, 12 Aug 2020 15:30:32 -0700 Message-Id: <20200812223045.96803-8-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200812223045.96803-1-alistair.francis@wdc.com> References: <20200812223045.96803-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=68.232.141.245; envelope-from=prvs=486123ee4=alistair.francis@wdc.com; helo=esa1.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/12 18:40:48 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] 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, URIBL_BLOCKED=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: , Cc: Alistair Francis , Richard Henderson , LIU Zhiwei Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: LIU Zhiwei Signed-off-by: LIU Zhiwei Signed-off-by: Richard Henderson Message-Id: <20200626205917.4545-5-zhiwei_liu@c-sky.com> Signed-off-by: Richard Henderson Message-Id: <20200724002807.441147-8-richard.henderson@linaro.org> Signed-off-by: Alistair Francis --- target/riscv/insn_trans/trans_rvd.inc.c | 8 ++++---- target/riscv/insn_trans/trans_rvf.inc.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/target/riscv/insn_trans/trans_rvd.inc.c b/target/riscv/insn_trans/trans_rvd.inc.c index ea1044f13b..4f832637fa 100644 --- a/target/riscv/insn_trans/trans_rvd.inc.c +++ b/target/riscv/insn_trans/trans_rvd.inc.c @@ -20,10 +20,10 @@ static bool trans_fld(DisasContext *ctx, arg_fld *a) { - TCGv t0 = tcg_temp_new(); - gen_get_gpr(t0, a->rs1); REQUIRE_FPU; REQUIRE_EXT(ctx, RVD); + TCGv t0 = tcg_temp_new(); + gen_get_gpr(t0, a->rs1); tcg_gen_addi_tl(t0, t0, a->imm); tcg_gen_qemu_ld_i64(cpu_fpr[a->rd], t0, ctx->mem_idx, MO_TEQ); @@ -35,10 +35,10 @@ static bool trans_fld(DisasContext *ctx, arg_fld *a) static bool trans_fsd(DisasContext *ctx, arg_fsd *a) { - TCGv t0 = tcg_temp_new(); - gen_get_gpr(t0, a->rs1); REQUIRE_FPU; REQUIRE_EXT(ctx, RVD); + TCGv t0 = tcg_temp_new(); + gen_get_gpr(t0, a->rs1); tcg_gen_addi_tl(t0, t0, a->imm); tcg_gen_qemu_st_i64(cpu_fpr[a->rs2], t0, ctx->mem_idx, MO_TEQ); diff --git a/target/riscv/insn_trans/trans_rvf.inc.c b/target/riscv/insn_trans/trans_rvf.inc.c index 0d04677a02..16df9c5ee2 100644 --- a/target/riscv/insn_trans/trans_rvf.inc.c +++ b/target/riscv/insn_trans/trans_rvf.inc.c @@ -25,10 +25,10 @@ static bool trans_flw(DisasContext *ctx, arg_flw *a) { - TCGv t0 = tcg_temp_new(); - gen_get_gpr(t0, a->rs1); REQUIRE_FPU; REQUIRE_EXT(ctx, RVF); + TCGv t0 = tcg_temp_new(); + gen_get_gpr(t0, a->rs1); tcg_gen_addi_tl(t0, t0, a->imm); tcg_gen_qemu_ld_i64(cpu_fpr[a->rd], t0, ctx->mem_idx, MO_TEUL); @@ -41,11 +41,11 @@ static bool trans_flw(DisasContext *ctx, arg_flw *a) static bool trans_fsw(DisasContext *ctx, arg_fsw *a) { + REQUIRE_FPU; + REQUIRE_EXT(ctx, RVF); TCGv t0 = tcg_temp_new(); gen_get_gpr(t0, a->rs1); - REQUIRE_FPU; - REQUIRE_EXT(ctx, RVF); tcg_gen_addi_tl(t0, t0, a->imm); tcg_gen_qemu_st_i64(cpu_fpr[a->rs2], t0, ctx->mem_idx, MO_TEUL); From patchwork Wed Aug 12 22:30:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 276647 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 411D5C433E0 for ; Wed, 12 Aug 2020 22:51:07 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 0AB8B20771 for ; Wed, 12 Aug 2020 22:51:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="de3wDI1X" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0AB8B20771 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:45388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5zaM-0002TE-AC for qemu-devel@archiver.kernel.org; Wed, 12 Aug 2020 18:51:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39600) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQY-0002OE-Ht for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:40:58 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:56480) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQV-0005oE-59 for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:40:58 -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=1597272055; x=1628808055; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nJLaTyf8APEUPNSKIY1asPcvSjkbcpRRCKeaBNyeFOc=; b=de3wDI1X6wwgOS9eJj7/nLdiKLXuSWLeUHvMj8lgeEKDz2JG28Luj9bK 7eC5h1dVVwEc7/YYmMPwCxddyC75sgx0K8ZGiqB1Vn4wXI9Q9X8CxiAxy 4f5nEmmiZF7lBhDgLLFq3iOL4NkbEV91SexQhzoniJGnnJBoEFlj7nQdH KzPjfOuvMxUwzywRi0O/Nr5dxuzvKyBfs1sVppxC2IX+U+IOIWkZVbapB AEHPawcugOq7i1qziifpz3SfTWAT9xJi3C9E1VXBF2Ojk7cghcZVXCgmV uuIq3G/P9P6qSzjJovqoG+jdZYyioz6EMjwtS/socqczleMGL9KKYmAzA A==; IronPort-SDR: qnKOyPDYm49BerO/YRJYEvnaJrZDPNU9zFW+Ca3pLd5x4P0R6zHq/v7xdOiamEEaBNBU8gZNgm HiZ3x0kJFLaAj9DYJNUCau/CJHJwFd58/h1bqY+Ek1g8kvZREfQ4SjosMtjSXFuyXERXaktA02 Hxk7BzTz1UL6iYq/QRnG6cH5ozbbhdc98svvcEAS46t9uh6xT/na8PhTH/Zwr3ROcHDYKkr0VV 1Th53eovbus3ex0qYEkhBOamDXzE7qVTIclKT4SKS4+BW1nfmMAGsEaM2fj4tQrHCXBA3PDxpL iU0= X-IronPort-AV: E=Sophos;i="5.76,305,1592841600"; d="scan'208";a="144853395" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 13 Aug 2020 06:40:49 +0800 IronPort-SDR: QSt6NjxLmCZTazLN6jSi2Cr60HWUzX/fVpM8g5js0TKxCEDf1BQZpxCXac97k3z1L34nDdWTY3 QJUWakxkM58w== Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 15:28:40 -0700 IronPort-SDR: cCNHF1TP77kv6l6EVevKeZ0butctWFhO5q3hR5GZOi1EVeRkpGLLOziNzXR2f0DGU5BVyxd915 5F4pXUdkBGXA== WDCIronportException: Internal Received: from jbfyk72.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.59.14]) by uls-op-cesaip01.wdc.com with ESMTP; 12 Aug 2020 15:40:46 -0700 From: Alistair Francis To: qemu-devel@nongnu.org Subject: [PULL 08/20] hw/riscv: sifive_u: Add a dummy L2 cache controller device Date: Wed, 12 Aug 2020 15:30:33 -0700 Message-Id: <20200812223045.96803-9-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200812223045.96803-1-alistair.francis@wdc.com> References: <20200812223045.96803-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.153.144; envelope-from=prvs=486123ee4=alistair.francis@wdc.com; helo=esa5.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/12 18:40:47 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] 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, URIBL_BLOCKED=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: , Cc: Bin Meng , Alistair Francis Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng It is enough to simply map the SiFive FU540 L2 cache controller into the MMIO space using create_unimplemented_device(), with an FDT fragment generated, to make the latest upstream U-Boot happy. Signed-off-by: Bin Meng Reviewed-by: Alistair Francis Message-Id: <1595227748-24720-1-git-send-email-bmeng.cn@gmail.com> Signed-off-by: Alistair Francis --- include/hw/riscv/sifive_u.h | 4 ++++ hw/riscv/sifive_u.c | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/hw/riscv/sifive_u.h b/include/hw/riscv/sifive_u.h index aba4d0181f..d3c0c00d10 100644 --- a/include/hw/riscv/sifive_u.h +++ b/include/hw/riscv/sifive_u.h @@ -71,6 +71,7 @@ enum { SIFIVE_U_DEBUG, SIFIVE_U_MROM, SIFIVE_U_CLINT, + SIFIVE_U_L2CC, SIFIVE_U_L2LIM, SIFIVE_U_PLIC, SIFIVE_U_PRCI, @@ -86,6 +87,9 @@ enum { }; enum { + SIFIVE_U_L2CC_IRQ0 = 1, + SIFIVE_U_L2CC_IRQ1 = 2, + SIFIVE_U_L2CC_IRQ2 = 3, SIFIVE_U_UART0_IRQ = 4, SIFIVE_U_UART1_IRQ = 5, SIFIVE_U_GPIO_IRQ0 = 7, diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index e5682c38a9..55b3383c31 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -72,6 +72,7 @@ static const struct MemmapEntry { [SIFIVE_U_DEBUG] = { 0x0, 0x100 }, [SIFIVE_U_MROM] = { 0x1000, 0xf000 }, [SIFIVE_U_CLINT] = { 0x2000000, 0x10000 }, + [SIFIVE_U_L2CC] = { 0x2010000, 0x1000 }, [SIFIVE_U_L2LIM] = { 0x8000000, 0x2000000 }, [SIFIVE_U_PLIC] = { 0xc000000, 0x4000000 }, [SIFIVE_U_PRCI] = { 0x10000000, 0x1000 }, @@ -302,6 +303,24 @@ static void create_fdt(SiFiveUState *s, const struct MemmapEntry *memmap, qemu_fdt_setprop_string(fdt, nodename, "compatible", "gpio-restart"); g_free(nodename); + nodename = g_strdup_printf("/soc/cache-controller@%lx", + (long)memmap[SIFIVE_U_L2CC].base); + qemu_fdt_add_subnode(fdt, nodename); + qemu_fdt_setprop_cells(fdt, nodename, "reg", + 0x0, memmap[SIFIVE_U_L2CC].base, + 0x0, memmap[SIFIVE_U_L2CC].size); + qemu_fdt_setprop_cells(fdt, nodename, "interrupts", + SIFIVE_U_L2CC_IRQ0, SIFIVE_U_L2CC_IRQ1, SIFIVE_U_L2CC_IRQ2); + qemu_fdt_setprop_cell(fdt, nodename, "interrupt-parent", plic_phandle); + qemu_fdt_setprop(fdt, nodename, "cache-unified", NULL, 0); + qemu_fdt_setprop_cell(fdt, nodename, "cache-size", 2097152); + qemu_fdt_setprop_cell(fdt, nodename, "cache-sets", 1024); + qemu_fdt_setprop_cell(fdt, nodename, "cache-level", 2); + qemu_fdt_setprop_cell(fdt, nodename, "cache-block-size", 64); + qemu_fdt_setprop_string(fdt, nodename, "compatible", + "sifive,fu540-c000-ccache"); + g_free(nodename); + phy_phandle = phandle++; nodename = g_strdup_printf("/soc/ethernet@%lx", (long)memmap[SIFIVE_U_GEM].base); @@ -733,6 +752,9 @@ static void sifive_u_soc_realize(DeviceState *dev, Error **errp) create_unimplemented_device("riscv.sifive.u.dmc", memmap[SIFIVE_U_DMC].base, memmap[SIFIVE_U_DMC].size); + + create_unimplemented_device("riscv.sifive.u.l2cc", + memmap[SIFIVE_U_L2CC].base, memmap[SIFIVE_U_L2CC].size); } static Property sifive_u_soc_props[] = { From patchwork Wed Aug 12 22:30:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 276650 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 733C4C433E0 for ; Wed, 12 Aug 2020 22:48:11 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 3AFDE20781 for ; Wed, 12 Aug 2020 22:48:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="gJIhqfV3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3AFDE20781 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60310 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5zXW-0005Sk-Fw for qemu-devel@archiver.kernel.org; Wed, 12 Aug 2020 18:48:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39576) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQW-0002K2-OZ for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:40:56 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:29819) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQU-0005m7-GO for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:40: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=1597272054; x=1628808054; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VWIRA4MvJfHg3q+KNZoxT6diO+bgU4E92KEQUmjiKA8=; b=gJIhqfV3ANbQeTzKYRSnXYVEiG6XJDwI4iC10xEoKmIyzxZBKazKAjdK Z3x+eXniE1dUqRHR1IL4prQMvyxjBDp9LXaw4qtTxM+K4QYJR2EBKxlLv /P76jFcfrsRFJUH592ocZqmyEUG477Rpnw7OvkUrDzeY7kdnvXsQLqRr4 uM6xl8mDylxvsF5wYU05GyVWNS2GC6wVVK3YSNqRcNetd7vOstqH72iCD p6A+hrF/CSVa6hNo0tsZlborShSrUDTOt2h+NeXd8fub/KuIeERxCZ633 eFURC17Eup1AbffDt/LRhKXmGnlcOITKv9SHkuQ2f9yj1qIQ1MyoXLW9w w==; IronPort-SDR: bmz7toj7N0KWvHMVmE9NZDQgRnozprObzDm1cwz9VFDHyxHpan/LsJhOH6L3l/L/GrP2Rp+g+W 9cStY+wMaJEVfYj8D0HCrYzyVI69Cg4nrVV8Ck+Tg0OOeQt4hrWH7Yklq5wQmu/b0PVa5vSHOs fXe2AVyJZvXEUkgNPuGxXGBwTUdrxVMOhTleIyYQN8lHKa5DTsaJ0jhnApinVVyraDkfD48j8I oygtwxexRbnBMdWXLOQ2toWoZ7raWhAEl1dU0S5IC/wUKNMT6oHVuz6itOs1SSaklGfBMPyWHL j3k= X-IronPort-AV: E=Sophos;i="5.76,305,1592841600"; d="scan'208";a="254208931" 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; 13 Aug 2020 06:40:49 +0800 IronPort-SDR: WA1mP93I0Jw6oip6CcELkjW5mMr+yxWbNns0UBk/qvFC7qwIgP/lSt5fSVhjRweaqGrvUnD1qy Php6tvWFshzQ== Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 15:27:57 -0700 IronPort-SDR: Wrn0z1g9+AbNO6pilbNAQvd7ZN8calFwyiDNw7pnqOvZjGPRi1uhsmCD879UvJZLKzrvPHpgB5 O2yI+kUE4yMg== WDCIronportException: Internal Received: from jbfyk72.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.59.14]) by uls-op-cesaip01.wdc.com with ESMTP; 12 Aug 2020 15:40:46 -0700 From: Alistair Francis To: qemu-devel@nongnu.org Subject: [PULL 09/20] riscv: Fix bug in setting pmpcfg CSR for RISCV64 Date: Wed, 12 Aug 2020 15:30:34 -0700 Message-Id: <20200812223045.96803-10-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200812223045.96803-1-alistair.francis@wdc.com> References: <20200812223045.96803-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=68.232.141.245; envelope-from=prvs=486123ee4=alistair.francis@wdc.com; helo=esa1.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/12 18:40:48 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] 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, URIBL_BLOCKED=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: , Cc: Hou Weiying , Alistair Francis , Myriad-Dreamin , Hongzheng-Li Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Hou Weiying First, sizeof(target_ulong) equals to 4 on riscv32, so this change does not change the function on riscv32. Second, sizeof(target_ulong) equals to 8 on riscv64, and 'reg_index * 8 + i' is not a legal pmp_index (we will explain later), which should be 'reg_index * 4 + i'. If the parameter reg_index equals to 2 (means that we will change the value of pmpcfg2, or the second pmpcfg on riscv64), then pmpcfg_csr_write(env, 2, val) will map write tasks to pmp_write_cfg(env, 2 * 8 + [0...7], val). However, no cfg csr is indexed by value 16 or 23 on riscv64, so we consider it as a bug. We are looking for constant (e.g., define a new constant named RISCV_WORD_SIZE) in QEMU to help others understand code better, but none was found. A possible good explanation of this literal is it is the minimum word length on riscv is 4 bytes (32 bit). Signed-off-by: Hongzheng-Li Signed-off-by: Hou Weiying Signed-off-by: Myriad-Dreamin Reviewed-by: Alistair Francis Message-Id: Signed-off-by: Alistair Francis --- target/riscv/pmp.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index 2a2b9f5363..b14feeb7da 100644 --- a/target/riscv/pmp.c +++ b/target/riscv/pmp.c @@ -320,8 +320,7 @@ void pmpcfg_csr_write(CPURISCVState *env, uint32_t reg_index, for (i = 0; i < sizeof(target_ulong); i++) { cfg_val = (val >> 8 * i) & 0xff; - pmp_write_cfg(env, (reg_index * sizeof(target_ulong)) + i, - cfg_val); + pmp_write_cfg(env, (reg_index * 4) + i, cfg_val); } } @@ -336,7 +335,7 @@ target_ulong pmpcfg_csr_read(CPURISCVState *env, uint32_t reg_index) target_ulong val = 0; for (i = 0; i < sizeof(target_ulong); i++) { - val = pmp_read_cfg(env, (reg_index * sizeof(target_ulong)) + i); + val = pmp_read_cfg(env, (reg_index * 4) + i); cfg_val |= (val << (i * 8)); } trace_pmpcfg_csr_read(env->mhartid, reg_index, cfg_val); From patchwork Wed Aug 12 22:30:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 276648 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C6E6C433E0 for ; Wed, 12 Aug 2020 22:49:44 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 694AE20771 for ; Wed, 12 Aug 2020 22:49:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="iAVPicas" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 694AE20771 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:39780 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5zZ1-00008b-L9 for qemu-devel@archiver.kernel.org; Wed, 12 Aug 2020 18:49:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39632) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQa-0002RU-9o for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:41:00 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:29831) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQU-0005qq-PC for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:40:59 -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=1597272054; x=1628808054; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9/GVwxO9Y3Bxpp+1tZOJ0aoCrDUf93MJirTx6uG5M4Y=; b=iAVPicasqjIPCjbaLUPeS+CQE051axDOxASjE9+ucuoa+IMfb58YkMf/ Pr2N+6BotTGWkvBFAzxU6ebdWTKHSz15swXfpiX+1uzkWjtt3IoU/15w2 SpbOE4SEbpFR8/piCH98TnN6kWuufLWOeJoFyvS1UG39XwtwfEd//dpJR LFPVZ8ljXPyj5bWRZDAFUxZJZIcg7Tp2jQF+oKu1zD/e9t7TrX3nP5kBu QfC+fUf3vve2mpWBzjLg/F+t4kAhuR5fCOgKRIpbt9DCYQBetWkMLUcw5 aYIpGmwDsV+I+s3nc7rMTJeIhJ6nbK5w201OsiK84fl2LpMDnYwAKMegQ A==; IronPort-SDR: t4Mi2qP23n4Dqy0Rd+9Zzr/hpQUmvCrQC+rOVvzZFy+/3xk1QDLCfnUCmqcMv2takBDtnY96xB JiKQRHabWjgJlLQQoDfvNFU1tAnTJlvUB8+cknZmC+9Em7nYlVb/CBzCgidRhAZT7j5h9JNwc2 N/IZSqPDqsvfC6whIjaNB0STa6W47aZatM8Lz3VvlGQUS9MH4bSTR7Y9kuTb9e1rq/lBAJI8od 0AZy0n2QHyFU++UAUqrf/nnJO+Zuqyj/4tLdNmCduoVWeY46aJTsNJgV92XkMA6/FAVYtyq7Jk L2I= X-IronPort-AV: E=Sophos;i="5.76,305,1592841600"; d="scan'208";a="254208932" 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; 13 Aug 2020 06:40:49 +0800 IronPort-SDR: iDH33lXy13VC088L5dDJzIu2cTYULzQ/y1cmZwI0nz8vwbqZOyvCLhgqDyH+DZDWR1pvW3XvSo 6zHe2Nh1oDww== Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 15:27:57 -0700 IronPort-SDR: EmCWnjfJHfCgyN0JsbGnif6YrOfVM4WxC/xPby7d9Xex6XaHlMBaZl+imSO98fA6IK1Xu36fp8 Ufh0TnlO5NLw== WDCIronportException: Internal Received: from jbfyk72.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.59.14]) by uls-op-cesaip01.wdc.com with ESMTP; 12 Aug 2020 15:40:47 -0700 From: Alistair Francis To: qemu-devel@nongnu.org Subject: [PULL 11/20] roms/opensbi: Upgrade from v0.7 to v0.8 Date: Wed, 12 Aug 2020 15:30:36 -0700 Message-Id: <20200812223045.96803-12-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200812223045.96803-1-alistair.francis@wdc.com> References: <20200812223045.96803-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=68.232.141.245; envelope-from=prvs=486123ee4=alistair.francis@wdc.com; helo=esa1.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/12 18:40:48 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] 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, URIBL_BLOCKED=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: , Cc: Anup Patel , Bin Meng , Alistair Francis Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng Upgrade OpenSBI from v0.7 to v0.8. The v0.8 release includes the following commits: 1bb00ab lib: No need to provide default PMP region using platform callbacks a9eac67 include: sbi_platform: Combine reboot and shutdown into one callback 6585fab lib: utils: Add SiFive test device 4781545 platform: Add Nuclei UX600 platform 3a326af scripts: adapt binary archive script for Nuclei UX600 5bdf022 firmware: fw_base: Remove CSR_MTVEC update check e6c1345 lib: utils/serial: Skip baudrate config if input frequency is zero 01a8c8e lib: utils: Improve fdt_parse_uart8250() API 0a0093b lib: utils: Add fdt_parse_uart8250_node() function 243b0d0 lib: utils: Remove redundant clint_ipi_sync() declaration e3ad7c1 lib: utils: Rename fdt_parse_clint() to fdt_parse_compat_addr() a39cd6f lib: utils: Add FDT match table based node lookup dd33b9e lib: utils: Make fdt_get_node_addr_size() public function 66185b3 lib: utils: Add fdt_parse_sifive_uart_node() function 19e966b lib: utils: Add fdt_parse_hart_id() function 44dd7be lib: utils: Add fdt_parse_max_hart_id() API f0eb503 lib: utils: Add fdt_parse_plic_node() function 1ac794c include: Add array_size() macro 8ff2b94 lib: utils: Add simple FDT timer framework 76f0f81 lib: utils: Add simple FDT ipi framework 75322a6 lib: utils: Add simple FDT irqchip framework 76a8940 lib: utils: Add simple FDT serial framework 7cc6fa4 lib: utils: Add simple FDT reset framework 4d06353 firmware: fw_base: Introduce optional fw_platform_init() f1aa9e5 platform: Add generic FDT based platform support 1f21b99 lib: sbi: Print platform hart count at boot time 2ba7087 scripts: Add generic platform to create-binary-archive.sh 4f18c6e platform: generic: Add Sifive FU540 TLB flush range limit override 13717a8 platform: Remove qemu/virt directory 65c06b0 platform: Remove spike directory d626037 docs: Add missing links in platform.md 7993ca2 include: sbi: Remove redundant page table related defines 5338679 lib: sbi_tlb: Fix remote TLB HFENCE VVMA implementation dc38929 lib: sbi: Improve misa_string() implementation 433bac7 docs: platform/generic: Add details about stdout-path DT property b4efa70 docs: platform/generic: Add details about IPI and timer expectations dfd9dd6 docs: Add platform requirements document c2286b6 docs: Fix ordering of pages in table of contents 7be75f5 docs: Don't use italic text in page title 63a513e lib: Rename unprivileged trap handler aef9a60 lib: Add csr detect support 13ca20d lib: Create a separate math helper function file 79d0fad lib: utils: Update reserved memory fdt node even if PMP is not present 6a053f6 lib: Add support for hart specific features b2df751 platform: Move platform features to hart 4938024 platform: fpga: Remove redundant platform specific features ec0d2a7 lib: timer: Provide a hart based timer feature 1f235ec lib: Add platform features in boot time print 22c4334 lib: Add hart features in boot time print 36833ab lib: Optimize inline assembly for unprivilege access functions 38a4b54 firmware: Correct spelling mistakes 28b4052 lib: sbi: detect features before everything else in sbi_hart_init() 4984183 lib: sbi: Improve get_feature_str() implementation and usage 3aa1036 lib: sbi: Remove extra spaces from boot time prints 3a8fc81 lib: sbi: Print platform HART count just before boot HART id 63b0f5f include: sbi: Use scratch pointer as parmeter in HART feature APIs 2966510 lib: sbi: Few cosmetic improvements to HART feature detection a38bea9 lib: sbi_hart: Detect number of supported PMP regions 89ba634 include: sbi: Add firmware extension constants 73d6ef3 lib: utils: Remove redundant parameters from PLIC init functions 446a9c6 lib: utils: Allow PLIC functions to be used for multiple PLICs 2c685c2 lib: utils: Extend fdt_find_match() Implementation d30bb68 lib: utils/irqchip: Initialize all matching irqchip DT nodes a9a9751 lib: utils: Allow CLINT functions to be used for multiple CLINTs 569dd64 lib: utils: Add fdt_parse_clint_node() function 6956e83 lib: utils/ipi: Initialize all matching ipi DT nodes a63f05f lib: utils/timer: Initialize all matching timer DT nodes 30b6040 Makefile: Fix builtin DTB compilation for out-of-tree platforms 64f1408 firmware: fw_base: Make builtin DTB available to fw_platform_init() 4ce6b7a firmware: fw_base: Don't OR forced FW_OPTIONS 86ec534 firmware: Allow fw_platform_init() to return updated FDT location c6c65ee Makefile: Preprocess builtin DTS 4e3876d Makefile: Add mechanism for platforms to have multiple builtin DTBs 72019ee platform: kendryte/k210: Use new mechanism of builtin DTB 51f0e4a firmware: Remove FW_PAYLOAD_FDT and related documentation 1b8c012 lib: Add RISC-V hypervisor v0.6.1 support 79bfd67 docs: Use doxygen config to mark the main page 106b888 docs: Remove redundant documentation about combined payload use case 9802906 platform: Add AE350 platform specific SBI handler 32f87e5 platform: Add AE350 cache control SBIs e2c3f01 lib: Fix __sbi_hfence_gvma_vmid_gpa() and __sbi_hfence_vvma_asid_va() 6966ad0 platform/lib: Allow the OS to map the regions that are protected by PMP 518e85c platform: Update Nuclei ux600 platform support d5725c2 lib: Don't print delegation CSRs if there is no S-Mode 637b348 lib: Fix the SBI_HART_HAS_MCOUNTEREN feature check db56ef3 platform: Add support for Shakti C-class SoC from IIT-M 9bd5f8f lib: sbi: Fix 32/64 bits variable compatibility 2314101 lib: Don't return any invalid error from SBI ecall a98258d include: Bump-up version to 0.8 Signed-off-by: Bin Meng Reviewed-by: Anup Patel Reviewed-by: Alistair Francis Message-Id: <1596439832-29238-3-git-send-email-bmeng.cn@gmail.com> Signed-off-by: Alistair Francis --- roms/opensbi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roms/opensbi b/roms/opensbi index 9f1b72ce66..a98258d0b5 160000 --- a/roms/opensbi +++ b/roms/opensbi @@ -1 +1 @@ -Subproject commit 9f1b72ce66d659e91013b358939e832fb27223f5 +Subproject commit a98258d0b537a295f517bbc8d813007336731fa9 From patchwork Wed Aug 12 22:30:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 276655 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73A7BC433E0 for ; Wed, 12 Aug 2020 22:42:29 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 39F0720774 for ; Wed, 12 Aug 2020 22:42:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="DAtmCeyF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 39F0720774 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:35920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5zS0-00044h-DW for qemu-devel@archiver.kernel.org; Wed, 12 Aug 2020 18:42:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39580) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQW-0002KX-WC for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:40:57 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:35621) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQU-0005qK-CY for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:40: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=1597272066; x=1628808066; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gxsKxLCPKdN4SFMA7S86ikuFrMubMYW40PaLwjnm0Jk=; b=DAtmCeyFSvUhHEEr8ZF2ZpbZ8ZQYy4vLrFA4DZDsS8ktfbfZ/XNjgwMX vLomoUhi/WBhxOO1OyIAA2yGq+XswRAehfkeZhEVL9qwibquaEkc9DTXX gw7Ed+PAYHb4LKulOnxmTgqO1U6QSkh50hfG+Hc1HQheT/XLjqqua2lYj hTegFQ3+m3bpNKxVNND3ghc6U6ymNKw1UAzwSE253QUPk1z7ic9rWcb/r Anw/ayCASE1CQ2j9VjSDNIKzEgYKLUM5qJTd8x1aWm2Ug+75D4gGCOrAM Qdi3mAAkpEoJWMtSf+7eXvzXzIsGt+U6tWZ1drJGOhgjzckSwNOTnd+5+ w==; IronPort-SDR: 2fNoGtUjF9XwMUMIRI605JqspteWkRoKH4MP1HWdrLGFOoMmEPNDkwmYGL2oIsshssMV4IJ7xh truPGmvExZWLcO7+5eSkE1qNJqHtDnAXqVGpsi5JpTdR04wB7GnPANQ2bYpofd9DgxJQns3XVB crSWdtXyNd3Ym2CbBBJJmW2AnRGDei/hx0YBCVm4nfzA4E51LrslTTBTCo9CcRab/1P6vXmhZY /2zgIBz5uLu9GbL1lmoeXhmRTQTWKEDJS3ISMT5hapuUAZ20fZQFbWl6HoNL+/QG/+GpXBA0Tt qoc= X-IronPort-AV: E=Sophos;i="5.76,305,1592841600"; d="scan'208";a="247966156" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 13 Aug 2020 06:41:03 +0800 IronPort-SDR: AWWVxNPOCCrJ55QKIEErrcP3SjlEjuhqx6PVB6P8gbx+AWsCSt72qxifOZSdgLbFT2CnGu2Op1 NuX/ClnscyYg== Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 15:28:43 -0700 IronPort-SDR: 5fxRkTj/rdP8CSoRy/rFrG6lw/n8NLazyDz0kXFYqqA6rTNTrNPJXp9yqSMSk6S+c92plSOtK8 AXQvyGpxzx+Q== WDCIronportException: Internal Received: from jbfyk72.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.59.14]) by uls-op-cesaip01.wdc.com with ESMTP; 12 Aug 2020 15:40:49 -0700 From: Alistair Francis To: qemu-devel@nongnu.org Subject: [PULL 15/20] gitlab-ci/opensbi: Update GitLab CI to build generic platform Date: Wed, 12 Aug 2020 15:30:40 -0700 Message-Id: <20200812223045.96803-16-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200812223045.96803-1-alistair.francis@wdc.com> References: <20200812223045.96803-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=68.232.143.124; envelope-from=prvs=486123ee4=alistair.francis@wdc.com; helo=esa2.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/12 18:40:52 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] 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, URIBL_BLOCKED=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: , Cc: Anup Patel , Bin Meng , Alistair Francis Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng This updates the GitLab CI opensbi job to build opensbi bios images for the generic platform. Signed-off-by: Bin Meng Reviewed-by: Anup Patel Reviewed-by: Alistair Francis Message-Id: <1596439832-29238-7-git-send-email-bmeng.cn@gmail.com> Signed-off-by: Alistair Francis --- .gitlab-ci.d/opensbi.yml | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/.gitlab-ci.d/opensbi.yml b/.gitlab-ci.d/opensbi.yml index 62088ec5ec..5b13047e2a 100644 --- a/.gitlab-ci.d/opensbi.yml +++ b/.gitlab-ci.d/opensbi.yml @@ -35,18 +35,14 @@ build-opensbi: when: always artifacts: paths: # 'artifacts.zip' will contains the following files: - - pc-bios/opensbi-riscv32-sifive_u-fw_jump.bin - - pc-bios/opensbi-riscv32-virt-fw_jump.bin - - pc-bios/opensbi-riscv64-sifive_u-fw_jump.bin - - pc-bios/opensbi-riscv64-virt-fw_jump.bin - - opensbi32-virt-stdout.log - - opensbi32-virt-stderr.log - - opensbi64-virt-stdout.log - - opensbi64-virt-stderr.log - - opensbi32-sifive_u-stdout.log - - opensbi32-sifive_u-stderr.log - - opensbi64-sifive_u-stdout.log - - opensbi64-sifive_u-stderr.log + - pc-bios/opensbi-riscv32-generic-fw_dynamic.bin + - pc-bios/opensbi-riscv32-generic-fw_dynamic.elf + - pc-bios/opensbi-riscv64-generic-fw_dynamic.bin + - pc-bios/opensbi-riscv64-generic-fw_dynamic.elf + - opensbi32-generic-stdout.log + - opensbi32-generic-stderr.log + - opensbi64-generic-stdout.log + - opensbi64-generic-stderr.log image: $CI_REGISTRY_IMAGE:opensbi-cross-build variables: GIT_DEPTH: 3 @@ -55,10 +51,6 @@ build-opensbi: - export JOBS=$(($(getconf _NPROCESSORS_ONLN) + 1)) - echo "=== Using ${JOBS} simultaneous jobs ===" - make -j${JOBS} -C roms/opensbi clean - - make -j${JOBS} -C roms opensbi32-virt 2>&1 1>opensbi32-virt-stdout.log | tee -a opensbi32-virt-stderr.log >&2 + - make -j${JOBS} -C roms opensbi32-generic 2>&1 1>opensbi32-generic-stdout.log | tee -a opensbi32-generic-stderr.log >&2 - make -j${JOBS} -C roms/opensbi clean - - make -j${JOBS} -C roms opensbi64-virt 2>&1 1>opensbi64-virt-stdout.log | tee -a opensbi64-virt-stderr.log >&2 - - make -j${JOBS} -C roms/opensbi clean - - make -j${JOBS} -C roms opensbi32-sifive_u 2>&1 1>opensbi32-sifive_u-stdout.log | tee -a opensbi32-sifive_u-stderr.log >&2 - - make -j${JOBS} -C roms/opensbi clean - - make -j${JOBS} -C roms opensbi64-sifive_u 2>&1 1>opensbi64-sifive_u-stdout.log | tee -a opensbi64-sifive_u-stderr.log >&2 + - make -j${JOBS} -C roms opensbi64-generic 2>&1 1>opensbi64-generic-stdout.log | tee -a opensbi64-generic-stderr.log >&2 From patchwork Wed Aug 12 22:30:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 276653 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F01CEC433E0 for ; Wed, 12 Aug 2020 22:44:14 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id BA4A020774 for ; Wed, 12 Aug 2020 22:44:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="Y8fnDNWs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BA4A020774 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:44410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5zTh-0007SO-WE for qemu-devel@archiver.kernel.org; Wed, 12 Aug 2020 18:44:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39614) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQZ-0002Ph-Gg for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:40:59 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:64096) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQU-0005qL-A0 for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:40:58 -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=1597272054; x=1628808054; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Cq3JJ2MpSltXdXGTDk4g6h8slBE4eUBzmWJR3+MONy4=; b=Y8fnDNWsohO1JGq4De+U6nQNkvnvouyPuwof0Lx19Un4mc1tgwf1ggGo 9BBNvT1jEkN4DmTm7wO8b5yb+fYB86xHKjP5kcYknEEEbutXCuXQao7nD 7Z6KxduFCN44mrHVTMmD4p9x/EjcaiRVYd9ilGLHGf8xcZjX43Do6Ninu wInAy8okkICwuiU4OTNFJYe63PEI15iZGPJffVP713t2WK+qdBr0ne5vU lGpUH4jt1nz4w1sToyAPcLqSTYLOnYcuda86wQZjdr04xl/9tl6pxDi0p TZYFQMds9Ds3N5K8fKKzXTNKTjiZ7ojW8wOMrcz51NR9YGUNyTCQShNm9 w==; IronPort-SDR: vzxksyaYzy0JPqvXAfWxATOa/VFuUVV7HXTuJT1MPOU+Tyr5uLCaeEDI8IjeUOi9nBpPaMu4sP y5g3Y+Ae2HXLTA0aOqsOghr+injqRWQRrQ4ao51yW3LJJkUjC1RGWzl2XCyI/Ehygp6CXoGUVW XVz2ajj137SdDV4M6CpOOCnyab5K0YH0qzB/ZJrdcdYruLuhsZu31qTLy0Pt+KyRdR4Mb4xkp6 5CF187fVShHcIWjVXfN8kxBEcXO5J/3NGhAN7hKmNC1o4GMQXBl9SzhhnN9ON52MVyLuPt7cFc rio= X-IronPort-AV: E=Sophos;i="5.76,305,1592841600"; d="scan'208";a="144799065" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 13 Aug 2020 06:40:52 +0800 IronPort-SDR: 06lz8vpcsuitd8R24fUqVXYNia/JwSWaJiYtVP8DMXAnQZiE/mmqSHisPEatgSCIyD/XedL2GJ Vwx7CgeX5P1w== Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 15:28:43 -0700 IronPort-SDR: CP1thwQz0Z8sWV+jU49rdnZVrFIPi1wnQxfChyD4c5GYZPFTvhUCp8pNR0IpIlxj4d+WYMZWwH WtVMH3HQM6Kg== WDCIronportException: Internal Received: from jbfyk72.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.59.14]) by uls-op-cesaip01.wdc.com with ESMTP; 12 Aug 2020 15:40:49 -0700 From: Alistair Francis To: qemu-devel@nongnu.org Subject: [PULL 16/20] target/riscv: Fix the translation of physical address Date: Wed, 12 Aug 2020 15:30:41 -0700 Message-Id: <20200812223045.96803-17-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200812223045.96803-1-alistair.francis@wdc.com> References: <20200812223045.96803-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=486123ee4=alistair.francis@wdc.com; helo=esa4.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/12 18:40:52 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] 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, URIBL_BLOCKED=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: , Cc: Alistair Francis , Zong Li Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Zong Li The real physical address should add the 12 bits page offset. It also causes the PMP wrong checking due to the minimum granularity of PMP is 4 byte, but we always get the physical address which is 4KB alignment, that means, we always use the start address of the page to check PMP for all addresses which in the same page. Signed-off-by: Zong Li Reviewed-by: Alistair Francis Message-Id: <370a983d0f9e8a9a927b9bb8af5e7bc84b1bf9b1.1595924470.git.zong.li@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/cpu_helper.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 75d2ae3434..2f337e418c 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -543,7 +543,8 @@ restart: /* for superpage mappings, make a fake leaf PTE for the TLB's benefit. */ target_ulong vpn = addr >> PGSHIFT; - *physical = (ppn | (vpn & ((1L << ptshift) - 1))) << PGSHIFT; + *physical = ((ppn | (vpn & ((1L << ptshift) - 1))) << PGSHIFT) | + (addr & ~TARGET_PAGE_MASK); /* set permissions on the TLB entry */ if ((pte & PTE_R) || ((pte & PTE_X) && mxr)) { @@ -630,7 +631,7 @@ hwaddr riscv_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) } } - return phys_addr; + return phys_addr & TARGET_PAGE_MASK; } void riscv_cpu_do_transaction_failed(CPUState *cs, hwaddr physaddr, From patchwork Wed Aug 12 22:30:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 276646 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 884EAC433E0 for ; Wed, 12 Aug 2020 22:52:24 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 0C6BA20771 for ; Wed, 12 Aug 2020 22:52:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="HnpMgmQa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0C6BA20771 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:49322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5zbb-00043N-3E for qemu-devel@archiver.kernel.org; Wed, 12 Aug 2020 18:52:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39666) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQc-0002Vh-Bu for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:41:02 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:64105) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQa-0005s1-EI for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:41:01 -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=1597272060; x=1628808060; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uwlOCs0TigAYqcOkVWOmrQqtoKu/av8RoK/zaQpBVm0=; b=HnpMgmQaVNDOIA10ULBnAsbLomOI6Xx2oNHhigueXzMd/4XgoelKgK5I TRheJ1MsvIdnd0TJG68/Kkgxcb0c4r5o1FVVlUiyps9SMU2b0xnflS0QZ tvwzQy9AlR7Ko6MAM9PF8jRtA8Iuc4Yajq7uprwj2c+/emfylXELhviTa 3UpSnSSLzvKPsTut1FFBJSluHCj/EmNnkLnyZO4c1Gkzml1QQcPJV2IoX osXPveSAwFDCCY5q/qEo5fxDhujGYPAaLitV1e/ZX6dJqfPayrzTgDTG6 WQXKt2b67fKostZ9cWYcFP/9HKa36Qr4rFzotnr7sHt0EMKZRPlusLbL1 g==; IronPort-SDR: 0YnxPfJmfDMoBy3/rgL3FA1UofknjBglYqu94/higO1RsB6InD7y8Q4Tf29/+3xLV4Ryl4rMzY LWf6UJMCtAoRYcubWB6OggL7OcqbBcesHH+QKYHkJZpJVBQdkB5f3FKTuHpgKIQ0wNb9n5efoC 6sJJZM9sQXM9Di/jbdM0wwLZ1qGyuY/wDLbG5xsWEI+DpUsoyaR2YqQ4yM111rEQy07xgrMV6S ZCZtqniK4AFKWdCjhnpoHef6uwBXwZoylzlFh1jQFYXqmFvc6r7S2MNgc3bM5IMlw+Z7fi+Sa0 5Nk= X-IronPort-AV: E=Sophos;i="5.76,305,1592841600"; d="scan'208";a="144799067" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 13 Aug 2020 06:40:52 +0800 IronPort-SDR: mX7zh4T7K4jmLuonTA0YzyFhsw8MBt4vSZxyn8uW6cZzBclrOFXxUBzYx+35kICSbn6rn6qFct OtnScLCfe5UQ== Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 15:28:43 -0700 IronPort-SDR: oPFmAF5AGu0z6pw6aiCz3UsLvV/75a37jnVaER4IjxdNzcyXpVBhFiSeUfzaO87jRMa4lcuayQ BtWV5QVlY1NQ== WDCIronportException: Internal Received: from jbfyk72.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.59.14]) by uls-op-cesaip01.wdc.com with ESMTP; 12 Aug 2020 15:40:50 -0700 From: Alistair Francis To: qemu-devel@nongnu.org Subject: [PULL 18/20] hw/intc: ibex_plic: Update the pending irqs Date: Wed, 12 Aug 2020 15:30:43 -0700 Message-Id: <20200812223045.96803-19-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200812223045.96803-1-alistair.francis@wdc.com> References: <20200812223045.96803-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=486123ee4=alistair.francis@wdc.com; helo=esa4.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/12 18:40:52 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] 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, URIBL_BLOCKED=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: , Cc: Jessica Clarke , Alistair Francis , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" After a claim or a priority change we need to update the pending interrupts. This is based on the same patch for the SiFive PLIC: 55765822804f5a58594e "riscv: plic: Add a couple of mising sifive_plic_update calls" Signed-off-by: Alistair Francis Cc: Jessica Clarke Reviewed-by: Philippe Mathieu-Daudé Message-Id: <0693aa700a4c67c49b3f1c973a82b257fdb7198d.1595655188.git.alistair.francis@wdc.com> --- hw/intc/ibex_plic.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/intc/ibex_plic.c b/hw/intc/ibex_plic.c index 41079518c6..578edd2ce0 100644 --- a/hw/intc/ibex_plic.c +++ b/hw/intc/ibex_plic.c @@ -121,6 +121,9 @@ static uint64_t ibex_plic_read(void *opaque, hwaddr addr, s->pending[pending_num] &= ~(1 << (s->claim % 32)); ret = s->claim; + + /* Update the interrupt status after the claim */ + ibex_plic_update(s); } return ret; @@ -140,6 +143,7 @@ static void ibex_plic_write(void *opaque, hwaddr addr, } else if (addr_between(addr, s->priority_base, s->priority_num)) { uint32_t irq = ((addr - s->priority_base) >> 2) + 1; s->priority[irq] = value & 7; + ibex_plic_update(s); } else if (addr_between(addr, s->enable_base, s->enable_num)) { uint32_t enable_reg = (addr - s->enable_base) / 4; From patchwork Wed Aug 12 22:30:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 276651 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D08A6C433E1 for ; Wed, 12 Aug 2020 22:46:13 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 9B19020771 for ; Wed, 12 Aug 2020 22:46:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="QqrZhlck" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9B19020771 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:52764 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5zVc-0002S0-RS for qemu-devel@archiver.kernel.org; Wed, 12 Aug 2020 18:46:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39730) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQi-0002k9-Ak for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:41:08 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:64096) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQc-0005qL-6T for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:41:08 -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=1597272062; x=1628808062; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6iYgSEaXu9Bo9J/ZFmcL7Vhvi/0ItyGMY2M76sAZop0=; b=QqrZhlckp6QtOwK2Km8KVXFYWU8F+Go+1XOBiucCPc80CkSbijtDrHJq sb39OAXCDsjVoSoV9HCwVetjNQjVn6FK627sssnOIRU7m9iVWbi2vHTzy CN+J7gvp2cjJqMV9QPxcvb87xDj/nG2g9Wq3OxIwaX1xdaI6HIgU3Opk9 K+WsMhXDPJfyEP7XUBbkHJWUWN/uZelL3mhyb9jfqWGpamOwHr61NkKYD /tKqHopaLLVC6Bpb24FmWkEhAoQf4mwDhG+PD5vQtMmboIsQRq36pCmqZ NwIYWgZDV/s+3SDbJ1E0ghlxf2A9sj0LwbG/oo+W4D7y7i6f/WUbnqGiH Q==; IronPort-SDR: YILx5Sh1yJVdLbCp94Snihma0ZIFD/Ub0w6rP0bZ3z/eXGmqDf6jVzRAD3SDPy1uqwEExIvBvo /u9ebsgts+umV8A6K9BeOdcdkKRWdb+C9pmBX4eOewq7C6+zUmB8rV+vAbMmQzBtnnnPycRXR2 Si1jQMrxaaMu3WqG32Pea9hSpKftGePJLimThaCzglWaQGkSqHs9N9EnX4M4UDU5ivLGXRfQ2g rCn6nZ3qDQ9C8+mR6NJjDP46e34CLHyz+fylafBL1FOxgZCfcKf8PLtdpLk5aEHk250KWjS9tc 5pM= X-IronPort-AV: E=Sophos;i="5.76,305,1592841600"; d="scan'208";a="144799070" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 13 Aug 2020 06:40:53 +0800 IronPort-SDR: RBJAnQxiB7LErrs07pwxM9ejEpsvR9iO1W+aOHZ4AcIHF0KvTZpRaD5xM5ywWizxw2/jbN2jvP MnDYISblGuhw== Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 15:28:44 -0700 IronPort-SDR: JMkO84N/din34kr6xxx7MmOW+bCtejYQSXuHF8vy6oLBIfNQz9arkF/9zgtGEMMVJcKiUTIOT0 gw4OekcDYxxQ== WDCIronportException: Internal Received: from jbfyk72.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.59.14]) by uls-op-cesaip01.wdc.com with ESMTP; 12 Aug 2020 15:40:50 -0700 From: Alistair Francis To: qemu-devel@nongnu.org Subject: [PULL 19/20] hw/intc: ibex_plic: Don't allow repeat interrupts on claimed lines Date: Wed, 12 Aug 2020 15:30:44 -0700 Message-Id: <20200812223045.96803-20-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200812223045.96803-1-alistair.francis@wdc.com> References: <20200812223045.96803-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=486123ee4=alistair.francis@wdc.com; helo=esa4.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/12 18:40:52 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] 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, URIBL_BLOCKED=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: , Cc: Alistair Francis Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Once an interrupt has been claimed, but before it has been compelted we shouldn't receive any more pending interrupts. This patche keeps track of this to ensure that we don't see any more interrupts until it is completed. Signed-off-by: Alistair Francis Message-Id: <394c3f070615ff2b4fab61a1cf9cb48c122913b7.1595655188.git.alistair.francis@wdc.com> --- include/hw/intc/ibex_plic.h | 1 + hw/intc/ibex_plic.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/hw/intc/ibex_plic.h b/include/hw/intc/ibex_plic.h index ddc7909903..d8eb09b258 100644 --- a/include/hw/intc/ibex_plic.h +++ b/include/hw/intc/ibex_plic.h @@ -33,6 +33,7 @@ typedef struct IbexPlicState { MemoryRegion mmio; uint32_t *pending; + uint32_t *claimed; uint32_t *source; uint32_t *priority; uint32_t *enable; diff --git a/hw/intc/ibex_plic.c b/hw/intc/ibex_plic.c index 578edd2ce0..669247ef08 100644 --- a/hw/intc/ibex_plic.c +++ b/hw/intc/ibex_plic.c @@ -43,6 +43,14 @@ static void ibex_plic_irqs_set_pending(IbexPlicState *s, int irq, bool level) { int pending_num = irq / 32; + if (s->claimed[pending_num] & 1 << (irq % 32)) { + /* + * The interrupt has been claimed, but not compelted. + * The pending bit can't be set. + */ + return; + } + s->pending[pending_num] |= level << (irq % 32); } @@ -120,6 +128,10 @@ static uint64_t ibex_plic_read(void *opaque, hwaddr addr, int pending_num = s->claim / 32; s->pending[pending_num] &= ~(1 << (s->claim % 32)); + /* Set the interrupt as claimed, but not compelted */ + s->claimed[pending_num] |= 1 << (s->claim % 32); + + /* Return the current claimed interrupt */ ret = s->claim; /* Update the interrupt status after the claim */ @@ -155,6 +167,10 @@ static void ibex_plic_write(void *opaque, hwaddr addr, /* Interrupt was completed */ s->claim = 0; } + if (s->claimed[value / 32] & 1 << (value % 32)) { + /* This value was already claimed, clear it. */ + s->claimed[value / 32] &= ~(1 << (value % 32)); + } } ibex_plic_update(s); @@ -215,6 +231,7 @@ static void ibex_plic_realize(DeviceState *dev, Error **errp) int i; s->pending = g_new0(uint32_t, s->pending_num); + s->claimed = g_new0(uint32_t, s->pending_num); s->source = g_new0(uint32_t, s->source_num); s->priority = g_new0(uint32_t, s->priority_num); s->enable = g_new0(uint32_t, s->enable_num); From patchwork Wed Aug 12 22:30:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 276649 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CA1AC433E1 for ; Wed, 12 Aug 2020 22:48:15 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 1A8C520838 for ; Wed, 12 Aug 2020 22:48:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="Tuw1IjAE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1A8C520838 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60602 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5zXa-0005a5-D7 for qemu-devel@archiver.kernel.org; Wed, 12 Aug 2020 18:48:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39738) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQj-0002nF-JV for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:41:09 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:64105) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5zQc-0005s1-JU for qemu-devel@nongnu.org; Wed, 12 Aug 2020 18:41:09 -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=1597272062; x=1628808062; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ecw+uUu8ObD0NK1lt/f/vE+UcPdy47ApeZdTtie3FrA=; b=Tuw1IjAEuzt0kw/X+OP0DbXSbBnfuhZOwXMg3+OvpQCEJisTO5c1a8Ev O7Hkb4bjgaI1PaVa6VXcgoaRWMVPaicRHF5E07kzdpmsvlK/pVa5WDfQ5 3elb5q0X4rW3++YBlT7pg5xxgEdVKbetq0KCYOziBcYhjUI4KINsv66zS bMl3y22dY05eQJziEsF1vHlNjrTlgOGG4D2F42jDU54Itk05TOTWxEtIN DHMMnzqs7J+eVEWuZR5CCV6ZbFPEISPto3K17AcZHRqfbRGmRqVEXuIRo +R9eMrJYyAew/YHPf/jSV8Kj5OySJAS9c2opliUYySAjlpcdG6GoFOxr4 w==; IronPort-SDR: bn99zlAFSxUZY3nTh2EyclWJTgYhITzNktSHk2muct5VCqRVriMoRgO1SVF/eOTvTjR/KE2ATm xcmuSvS/KKuZwsGNExHxvjl/rPIiVMzFNCSmuhpXo9ZK3DO3qd6RnAAk9WXbCCQczyCVYLqghP OCcK95ztfBAwln9+Z7E5GS7MoKKuZqMgnlk6sTX+ktsVhCgKbm96b3RobE0IVYbY0ssa2ZQ/VR CLLoDbNPupu9lJXCLUDwldlsO9UHun5h/VSCd84zbPam3kdbkJhl8IGxcirKwDW8M4rYpfYAmT y2k= X-IronPort-AV: E=Sophos;i="5.76,305,1592841600"; d="scan'208";a="144799071" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 13 Aug 2020 06:40:53 +0800 IronPort-SDR: I1adoBX9g2wZ2ErZZcY4rp+FyEJlQuV4D1kDjudx3gDmL4n5xEX78C3r5zHuy03ojpro3C1cjE iQ67TTswp/rw== Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2020 15:28:44 -0700 IronPort-SDR: rS/BsqfsaliAix2VApE+QKfmcCd/nECEY3UhgCvuFDAuOLxJi2BvDmGxtvZkeHlSURgSgito9w SNy6ZSpEUB9A== WDCIronportException: Internal Received: from jbfyk72.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.59.14]) by uls-op-cesaip01.wdc.com with ESMTP; 12 Aug 2020 15:40:50 -0700 From: Alistair Francis To: qemu-devel@nongnu.org Subject: [PULL 20/20] hw/intc: ibex_plic: Honour source priorities Date: Wed, 12 Aug 2020 15:30:45 -0700 Message-Id: <20200812223045.96803-21-alistair.francis@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200812223045.96803-1-alistair.francis@wdc.com> References: <20200812223045.96803-1-alistair.francis@wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=486123ee4=alistair.francis@wdc.com; helo=esa4.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/12 18:40:52 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] 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, URIBL_BLOCKED=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: , Cc: Jessica Clarke , Alistair Francis , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This patch follows what commit aa4d30f6618dc "riscv: plic: Honour source priorities" does and ensures that the highest priority interrupt will be serviced first. Signed-off-by: Alistair Francis Cc: Jessica Clarke Reviewed-by: Philippe Mathieu-Daudé Message-Id: --- hw/intc/ibex_plic.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/hw/intc/ibex_plic.c b/hw/intc/ibex_plic.c index 669247ef08..f49fa67c91 100644 --- a/hw/intc/ibex_plic.c +++ b/hw/intc/ibex_plic.c @@ -57,6 +57,8 @@ static void ibex_plic_irqs_set_pending(IbexPlicState *s, int irq, bool level) static bool ibex_plic_irqs_pending(IbexPlicState *s, uint32_t context) { int i; + uint32_t max_irq = 0; + uint32_t max_prio = s->threshold; for (i = 0; i < s->pending_num; i++) { uint32_t irq_num = ctz64(s->pending[i]) + (i * 32); @@ -66,14 +68,17 @@ static bool ibex_plic_irqs_pending(IbexPlicState *s, uint32_t context) continue; } - if (s->priority[irq_num] > s->threshold) { - if (!s->claim) { - s->claim = irq_num; - } - return true; + if (s->priority[irq_num] > max_prio) { + max_irq = irq_num; + max_prio = s->priority[irq_num]; } } + if (max_irq) { + s->claim = max_irq; + return true; + } + return false; }