From nobody Sat Nov 23 18:10:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=sifive.com ARC-Seal: i=1; a=rsa-sha256; t=1732088918; cv=none; d=zohomail.com; s=zohoarc; b=Ooj558sDqOO80dLXuDhxYPoeZjM1ddrFf7ZSNcCUZByilbvrNag3KFfxPT8Pxs1HU8VRFp6LB96u8CLxt4P95nnMvbW01a7VTH6eui+3T9G1q9Xv/a4JWulCJ8HjtCdAB/IWk+BelKiwY8MClPvfbGSpRamPjK45zR3oCvc74dI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732088918; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hvzvoO5brrLYHxKu/Ou4AE457DWwgARUuUV3MJMIxX4=; b=gfkRfDw334X9dRv219AnOMaAJlI8rRN5FhN3FQbMIiE2v1gp4nXdqUSbiPmwYpVEFIt+2+FcaT2RqiM5o0FgSVFMZq7845m+MpB0ibYabRvah5pa5i7KSZ60EYwBE/MdL5uuK/S5xXekT/1wMKuqPMF8TeVYO2+ubJBVNhO0O4A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1732088918452231.33787801079927; Tue, 19 Nov 2024 23:48:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tDfQK-0002SH-58; Wed, 20 Nov 2024 02:46:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tDfQI-0002QS-1Q for qemu-devel@nongnu.org; Wed, 20 Nov 2024 02:46:50 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tDfQF-0006QO-A5 for qemu-devel@nongnu.org; Wed, 20 Nov 2024 02:46:49 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-212776d6449so302185ad.1 for ; Tue, 19 Nov 2024 23:46:46 -0800 (PST) Received: from hsinchu36-syssw02.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211d0f51fe0sm86206255ad.233.2024.11.19.23.46.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2024 23:46:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1732088805; x=1732693605; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hvzvoO5brrLYHxKu/Ou4AE457DWwgARUuUV3MJMIxX4=; b=CE7XhGPkyPWyxo7xUFeq83w4NzOoXKD/epWoOPEnYxZkUkKIQMmRRqAd1+kF1msq1D 974jgXPd7QvUKvcOo7idWEpUiOXLIlp72P4n6LaWsUpEtoLoPTO+aEuZLnfRnK3/Yu7A 4ZwrMUWXeZl9efvU+8dVbADR/enSNPTS+Lxcdii5vKnFMB+ZryfDAIh6iNV3H41woktR y5YPsTAEwo+RGGsWKoVfiDBIi9rn2LrgU4OYWUwY9socBDW91FQ1k6O08kzn+bMnel6B EAF4pBcicsFgmUYsFcDCASWG/tumt++RCUiu8lm06AeTBdoMp46ONriZKCQ8Bc5UpfGh 8Mfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732088805; x=1732693605; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hvzvoO5brrLYHxKu/Ou4AE457DWwgARUuUV3MJMIxX4=; b=muffz1D8kt7sEEmxoOq3gKTtEDDPDFpg5LZa8ODg/r1jmqkni4A+xuH+GGx7K1HuzP a83nb7rhD9vXEPFdSY0PzVJNIceC5il14jQGUtGdJuD6lKK3qQOY58fkwMqp+yRFScRp jMftDWWoJkAKc4txF0pKRKJ0gSQyua/z0wW0v2scOTKOaUE+Ek7cKT7zOphhZiqx0aJZ G5SvFivHeaQVISKkvSnkKW07bqNZ4YhZD63V7Qa2K6M2Lkce6kL+LKGo5t7DIkqAjTJQ lefccTFNfYbznez/1Or+0ME8DZucuwB9FLwXIpx923NL/NogP4RdX+EAndwP6rjtAMSF 5zJg== X-Gm-Message-State: AOJu0Yy5C19QJsQ0juxhE979DswoJvzs9PH94FjD1ENnhdn3BAksIn3y kCbSjQ52kBNmgP+Wr2T2XREhkIn6PfVPWDUJYQNKHSKfRgtEtTMCzf7eZrdGfjy4eQruB5UMmPb FzgZzYxsuId9pkr8wr4YX1wOP87pI/8zQrQlhGXTkUxoG7JmzmpPKyX2C2CyLGTSk9vC6qUhWHz EM6qegirnmdLmgEUKx/tO5hLg9Lr4jXUcKilc= X-Google-Smtp-Source: AGHT+IF6nRdpWv1AfiP3UFwmy1yuIt1r9YmXhTV7T9KQcGgymz3ZFI4RY5hGtgFwo031oOrdXHOWUA== X-Received: by 2002:a17:902:f652:b0:212:530:a65d with SMTP id d9443c01a7336-2126fd89c9bmr13159015ad.38.1732088804697; Tue, 19 Nov 2024 23:46:44 -0800 (PST) From: "Fea.Wang" To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , "Fea.Wang" , Frank Chang , Jim Shu Subject: [PATCH v4 3/6] target/riscv: Support hstatus[HUKTE] bit when svukte extension is enabled Date: Wed, 20 Nov 2024 15:48:51 +0800 Message-Id: <20241120074854.1767780-4-fea.wang@sifive.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241120074854.1767780-1-fea.wang@sifive.com> References: <20241120074854.1767780-1-fea.wang@sifive.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=fea.wang@sifive.com; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @sifive.com) X-ZM-MESSAGEID: 1732088919517116600 Content-Type: text/plain; charset="utf-8" Svukte extension add HUKTE bit, bit[24] in hstatus CSR. The written value will be masked when the svukte extension is not enabled. When hstatus[HUKTE] bit is set, HLV/HLVX/HSV work in the U-mode should do svukte check. Signed-off-by: Fea.Wang Reviewed-by: Frank Chang Reviewed-by: Jim Shu Reviewed-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis --- target/riscv/cpu_bits.h | 1 + target/riscv/csr.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index 4b9f899217..fe4e34c64a 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -604,6 +604,7 @@ typedef enum { #define HSTATUS_VTVM 0x00100000 #define HSTATUS_VTW 0x00200000 #define HSTATUS_VTSR 0x00400000 +#define HSTATUS_HUKTE 0x01000000 #define HSTATUS_VSXL 0x300000000 =20 #define HSTATUS32_WPRI 0xFF8FF87E diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 1936a6f32a..b6fa8ae53f 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -3540,6 +3540,9 @@ static RISCVException read_hstatus(CPURISCVState *env= , int csrno, static RISCVException write_hstatus(CPURISCVState *env, int csrno, target_ulong val) { + if (!env_archcpu(env)->cfg.ext_svukte) { + val =3D val & (~HSTATUS_HUKTE); + } env->hstatus =3D val; if (riscv_cpu_mxl(env) !=3D MXL_RV32 && get_field(val, HSTATUS_VSXL) != =3D 2) { qemu_log_mask(LOG_UNIMP, --=20 2.34.1