From nobody Sat Nov 23 15:26:32 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=1732088900; cv=none; d=zohomail.com; s=zohoarc; b=Ka6DiTslXcYL9/JIxk0mAa3dyrix6NiixFarYy5pGS3V7J66ZCaPDKEjclp/sh32vRlTgaAfQTN607Pa1wZZAKhV/mFqjD2By9QhJJ+XGJi+WlfjOF7hGJbJ+oJh9qx4lWBAnUNOINt4x91c3csVSXJRNcRZCCDVpVeB4144inE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732088900; 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=HRHaR9pcBAF9H3M4At6noJSbZrF61K68F3kyhCd72IY=; b=F1IcWJ6csfA1TbNzhhbJAjELAnVAXebSV/r3ea8xc5k/y8qsJuiWyoqBqxwmab3iSaqQMeHGItcRrwtR4MTPhVaXg3dc7J1fIWSfb0ctU8HfnNAI3Yb5vzpXZaJM8oNzBFvCNVEWXE86Be8GnKgsrfKurKtdGTDHS2oTJEV6LA8= 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 17320889001485.8624204437934395; Tue, 19 Nov 2024 23:48:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tDfQF-0002PS-Km; Wed, 20 Nov 2024 02:46:47 -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 1tDfQA-0002OU-Qm for qemu-devel@nongnu.org; Wed, 20 Nov 2024 02:46:44 -0500 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tDfQ9-0006PG-95 for qemu-devel@nongnu.org; Wed, 20 Nov 2024 02:46:42 -0500 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-7ee51d9ae30so3092144a12.1 for ; Tue, 19 Nov 2024 23:46:40 -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.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2024 23:46:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1732088800; x=1732693600; 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=HRHaR9pcBAF9H3M4At6noJSbZrF61K68F3kyhCd72IY=; b=O37um4Fyx3sMCD/6QODtos4skTx21fc18kxLuGToLxTl3M2KfMtrrEiUC92+xVINBG izEJ1WDyfBJpt9B25K/PDc9nxQKtXl3sJsyXKYZXIRsbnGL4hS2ltDhYyZyjRwNUZ8Ma l4Bxtt3Ujs2x63RPWbTQPt+uIkmKTupwr77ERgskUF6kjc/oTeLNIOCTdsSFkzPgkuYt Z9ftq/kbJRCzKLKLhjiSZJUIVivIVDPLagM+alnlDMHDvvk7PS1rctD0VvKrWn/9ukV1 i5CABcVxSt4SxSjJ2v10mXY9dLmfhRihsBITBJPurrVrn3oT8SbE3Bv/LbL7LZ8BWxyG j2Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732088800; x=1732693600; 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=HRHaR9pcBAF9H3M4At6noJSbZrF61K68F3kyhCd72IY=; b=WtJZYAs1du9cr211gawf97G7nKwBHjo281RczKiW7yJIc0RBvLN7u/3XpNOKFcLM7z LLrZWrYGQsW/4LXYIZpuke5CVPDlTXusA0AmWki6kE763z8e5BJDV7sACR08pMSw10dY sMimnGZaaBG/lZdtYQFNGO1+KrnwRrkmLTD+o0Mclc9RvdWDqJz5IK1rNvXrRLwjKugv eLQtP2CkalM8lrfn+4Z129U08Zi0V2vWTRJJyntxtUUjcaCarugDcafWQxLKVXt3hpfs iYptTnzVBMaFkzhMPQlSrb7HW8G+EMQyjaBCSA6z8V3qQu7Ou1pbmNsaf4JaHC3w5if0 1NEg== X-Gm-Message-State: AOJu0YyWzUbxQwWw2zbWjgPO0uY/B/hoPPdobeVK2iQdotrpkwxLyK7R AhYbVpwVTnm6r8zv7x4qW0qmO/Tjldw2SlW+jMDMnk6PDdTl34fkObQpOV1qoIc/h0z7PHumvw0 augL+1ldD+7tTryu37jHk+p862WnQ9yOjyktJCEmrk4BXkbdBxuRXCvfHgm5PWa8wOiZN+5ZDve Zam3Ay+4LFEBmWTbpgjjWAQ5uGAj1StFzSbAM= X-Google-Smtp-Source: AGHT+IHqhWv6J413TU13WsyC8gl1egXxQ/eIZHTFWmLXR4B4ToJ1WO1qNLAM8crBNbdRN1dvXXVaTQ== X-Received: by 2002:a05:6a20:9195:b0:1db:e1b0:b673 with SMTP id adf61e73a8af0-1ddae2f047bmr2563194637.9.1732088799524; Tue, 19 Nov 2024 23:46:39 -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 1/6] target/riscv: Add svukte extension capability variable Date: Wed, 20 Nov 2024 15:48:49 +0800 Message-Id: <20241120074854.1767780-2-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::534; envelope-from=fea.wang@sifive.com; helo=mail-pg1-x534.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: 1732088901316116600 Content-Type: text/plain; charset="utf-8" Refer to the draft of svukte extension from: https://github.com/riscv/riscv-isa-manual/pull/1564 Svukte provides a means to make user-mode accesses to supervisor memory raise page faults in constant time, mitigating attacks that attempt to discover the supervisor software's address-space layout. 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_cfg.h | 1 + 1 file changed, 1 insertion(+) diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h index 59d6fc445d..d8771ca641 100644 --- a/target/riscv/cpu_cfg.h +++ b/target/riscv/cpu_cfg.h @@ -84,6 +84,7 @@ struct RISCVCPUConfig { bool ext_svnapot; bool ext_svpbmt; bool ext_svvptc; + bool ext_svukte; bool ext_zdinx; bool ext_zaamo; bool ext_zacas; --=20 2.34.1 From nobody Sat Nov 23 15:26:32 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=1732088920; cv=none; d=zohomail.com; s=zohoarc; b=eBpEIobOu1NxxuUT85Qvqy7dMepHFWG7VjyySUn/WYJi+6Bz0vn4tXfRppFus9pNzONt65AMWp+erPAMOZQpK9gfRzeTqGfCRAq2tPquIxsvZap0ErQEbQgY6rdd5fHk782QHcP42X8YhsQDQC3VQWmusm3rHgs4eCjM38eN7oA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732088920; 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=1n5F45dnj2huToG/m+cqtyxGgXbbcrTnolugdKwwrfo=; b=nZQIIKO8KuCXQIplpyeKgBj67E+VfMU0jR5+d00zbdIOAAvJlfMm9jmjhJOCw+d6uXQGp6gAroU3Qz2pAm/9p9eQP0vImX4ulefy6p9gGsXyA4zMHx5Z8WFlE7rIo+yPgAcn6vjSfHOl/FUpfbyWCWs5UthrW65HL99eWaDS0ZQ= 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 1732088920645527.9509275524446; Tue, 19 Nov 2024 23:48:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tDfQI-0002RO-Gp; Wed, 20 Nov 2024 02:46:50 -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 1tDfQG-0002Q7-Nc for qemu-devel@nongnu.org; Wed, 20 Nov 2024 02:46:48 -0500 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tDfQF-0006Q0-7e for qemu-devel@nongnu.org; Wed, 20 Nov 2024 02:46:48 -0500 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-21210eaa803so34117545ad.2 for ; Tue, 19 Nov 2024 23:46:43 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2024 23:46:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1732088802; x=1732693602; 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=1n5F45dnj2huToG/m+cqtyxGgXbbcrTnolugdKwwrfo=; b=AO6V9i9RbnswE42OcdcqNbHxiVuTxCGZmTIq+6ojXptEnoR5i3jB7+Pt2zvT8u24pA DpqE1Q0xHpbo1AGxo1K+NuaJGLhdYAMZ+3sXTiLM05Svcqrpt8muWZUnKE/52uddjBdB iFw+2cWIKdtG9vLXjLOM2MS8zvwmaEZt0sPwOI+y+AgoEABaFjfZyYWQD0F43KgAkYXl MLBPS3A0SGKYA1nYJE28JTBzL1wBqldAzaRtHnMtMRSGbilfI631b1X3y5o3g95h1CtC 7gSE65g7+31dy8WVD87MKCcjf9jzbyXrp/uTjcOF1Pp6PiuUXxJeO5x8K8KWgkOgZ6vs DrWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732088802; x=1732693602; 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=1n5F45dnj2huToG/m+cqtyxGgXbbcrTnolugdKwwrfo=; b=Wcq30tqvLbD9gBH0wLpRxufGWt+9l3duTI74XGpSGy6rDK8ANAsi/pjXw5HSb2B+oA OBYnABsWHcxd1q+Jr0so5UpKkXEoZx9XepdJ5OnrKLSc/nRwQHgHcSR/PnEwPEdQRbD6 eznuAcsu2GdTIFR4ZfYjyNYfSjIfeCjSIeqRCo0aXcOcW6RCwA3ucw4pXKLK9pJdQ/4s IREpjeyBlLETOCkXx9colf3Egh0FKMSa+VKuf43rMxF+3/ZomSLo7WOp5V5s2SjCU2og RVIC+yYza2D0T9C3CiZqzlECKBqKXjvBv7Nq+uzvNdSQSFqyA9z8bTheH2jzz3NxBCli uppQ== X-Gm-Message-State: AOJu0YxXlhGvN/9+FK57M+tj8ebxiDNb5F6V09KNBbXTE5uHTj/VjYHB qKDrnoMl1jhdQa4jN0RIKuxIgjSNQhJ1xURPcGyNU0Nj7rgqNtnpM7gPbYNXKA6/xPKVkxSj0QL MPUPWe6f5psEXnt5egqstC39oJ5+1hRfxxCtJkSXMJPXOwdQM0qIBw36scVa2l8IeEXpprYk2u4 2JqHWJ0hblMRn2n9Fe7QdvBHmZMFpZ6Eic2Ek= X-Google-Smtp-Source: AGHT+IF2hBtdNi2m2sZNIY3d4txVg4S42FuD+JBouPgnunijA8ENaf1HWjN94gQ6qWq76kRqhBmrSQ== X-Received: by 2002:a17:902:e550:b0:20c:9ec9:9a77 with SMTP id d9443c01a7336-2126a4750abmr19304045ad.37.1732088802112; Tue, 19 Nov 2024 23:46:42 -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 2/6] target/riscv: Support senvcfg[UKTE] bit when svukte extension is enabled Date: Wed, 20 Nov 2024 15:48:50 +0800 Message-Id: <20241120074854.1767780-3-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::62f; envelope-from=fea.wang@sifive.com; helo=mail-pl1-x62f.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: 1732088921280116600 Content-Type: text/plain; charset="utf-8" Svukte extension add UKTE bit, bit[8] in senvcfg CSR. The bit will be supported when the svukte extension is enabled. When senvcfg[UKTE] bit is set, the memory access from U-mode should do the svukte check only except HLV/HLVX/HSV H-mode instructions which depend on hstatus[HUKTE]. 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 | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index 385a2c67c2..4b9f899217 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -785,6 +785,7 @@ typedef enum RISCVException { #define SENVCFG_CBIE MENVCFG_CBIE #define SENVCFG_CBCFE MENVCFG_CBCFE #define SENVCFG_CBZE MENVCFG_CBZE +#define SENVCFG_UKTE BIT(8) =20 #define HENVCFG_FIOM MENVCFG_FIOM #define HENVCFG_LPE MENVCFG_LPE diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 9846770820..1936a6f32a 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -2453,6 +2453,10 @@ static RISCVException write_senvcfg(CPURISCVState *e= nv, int csrno, mask |=3D SENVCFG_SSE; } =20 + if (env_archcpu(env)->cfg.ext_svukte) { + mask |=3D SENVCFG_UKTE; + } + env->senvcfg =3D (env->senvcfg & ~mask) | (val & mask); return RISCV_EXCP_NONE; } --=20 2.34.1 From nobody Sat Nov 23 15:26:32 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 From nobody Sat Nov 23 15:26:32 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=1732088892; cv=none; d=zohomail.com; s=zohoarc; b=elseNd2vj1b61omOhd1U08d5Yj69DTUGhDJkZzrp1scsl4CP2Puz87EMdtsj5deUYWnGzGIO5NMqAyc5PR6FqLY19BT3Mp9kPVluyDwE/HnctxQBUj4nBHfahKTzexkaAYi/8zEXJpsj7I+vx9CLBfCanuOSPz4+mEgVM6/lS2c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732088892; 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=s5NXDXiAf6nuE9+jlkJ/8ZDxukjz+9DMfhSzOI8Deco=; b=bOL0hn0rFvIDj6lUnXHNM+31bPdtHDfPAHJLR26LA26bF4QKOsBxEXDHRUcV8qTWOAiZLyhas74DXlABl/LlSBI1imk2PRUivqKsttPSr+B+dFP6uriO55WW4sXpwR2p5pRWnm9n6YI+KfgFJTHmrF1ErzQ6SkwKWnqDapiC96c= 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 1732088891997200.9274433600748; Tue, 19 Nov 2024 23:48:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tDfQO-0002UC-1B; Wed, 20 Nov 2024 02:46:56 -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 1tDfQM-0002T8-8h for qemu-devel@nongnu.org; Wed, 20 Nov 2024 02:46:54 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tDfQG-0006Qk-Rb for qemu-devel@nongnu.org; Wed, 20 Nov 2024 02:46:54 -0500 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-20cb7139d9dso18654405ad.1 for ; Tue, 19 Nov 2024 23:46:48 -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.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2024 23:46:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1732088807; x=1732693607; 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=s5NXDXiAf6nuE9+jlkJ/8ZDxukjz+9DMfhSzOI8Deco=; b=CbeIiy+kWl7/AF+OYHSlsBT4INnoTeSBBQGjMLFrYIoJO2OiL6QEGFX15cxCypydSY sGqOGMBez2NVitUEY7kSVCrhLPsnhWH45zETtj0eJ7sDxFPPXAwwPQ5f+h2uonvarDEu m92KD/KhYIe3bbrFAER8XPb/m4TaNwHcOlwaexhCSL8ibxKH7FAab7vE7byEP4S80y5u hnlrg0chpr1cUB5u0xzdrksrrON6Fopcts5y+FhxGlu621H0LZoYg21PW/s4giHSpkvR LnZBylkgRVisO6TsJTuApMbPiTmcab6+r4sXvrswnlldX/FPrAQEyF6P3Jocff/WJZmP LXwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732088807; x=1732693607; 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=s5NXDXiAf6nuE9+jlkJ/8ZDxukjz+9DMfhSzOI8Deco=; b=iI/ljsoB2mUsNA1bWM7C7dwptP8OGNOPHcmVwVxlHLrGCCOssOutFXNcGDSUxIFa4q pwR3u7bAXKakgfG90ZjWD1nbPx+TkQpkJc/qlekaL+EGphZDNne7Oq4df5/IpS7GjJbv 1gq9pQgkC0pbshi3TZtmPgxuqYlFWMeITCenVLZv/ye8qXsnZBHhhsYDHL4dhb73WPgf ediCCxQSu0wi4x9ewFY5cixLErst3iZhrKZTi8lGDChwk14WLyA4Pxk5lJnmmNmneYG/ PScJH/ZStiDlBAmpVPeHTmGa5GegUKNLiKn+9OeJV6KY/aUTEFLzltgcHC5PF2H6thpG cXmw== X-Gm-Message-State: AOJu0YzCsY5lPO2OOzOFQDKD23+T2+mCj/SG9hcV2q+w5tVoV9rwbOTu fIPnrw6Sb77lE/O5sVFGQpP2+17MoIsA5KDlbYoYfm+2uTnWoX2tLNz/ZM2JIe4iX1URjx5AWRF ke1g4c1rnDaG37VFc9jZw7163C6grmPrOGXlNo/CLh7vc5qT9JtOYmARztDpaoGbnYl4BDlSqVh JFIKBZP8ZtvdzFLPpbIjCzLVzP6G3ppg3dVFQ= X-Gm-Gg: ASbGncsoO1PU8hynE1onkZonhqcO1hwF4k3MrHYccGlhAHlfmwAPc6NCQkrmPuOkY8L 5W32Y4SSkBGoxsd1ESjJdjmqbXPIKfGl9Ba54wdUFhSzTA/Z9sgSZiAJ8Uhbh1l6xYKobCg8u08 IjBnOLMmkgyqsP38V4/39TN9rsOTdF19NNwT6Tr66Fefnt6aXJwIv/5emQv6wJM/TBrRwbvHDyR 2zwVqqyicoO2GevLrkoBCvMCdJc2H7Cs8yC559yOS0sVsQfYs/3E5NHiVnVQ4X389VUPgxKL0PA ch7nLBhZTWwp66WigeRweYcWyf6jV28roj570wGubQ== X-Google-Smtp-Source: AGHT+IGrhehldMEdxERdueUWf135SWsdhHLzmIloTJTFHxN/4dgqXAGOWkAwPb4nN0hLSIC/Dk9/7w== X-Received: by 2002:a17:902:ec89:b0:20c:9326:559 with SMTP id d9443c01a7336-2126a3ec896mr19685075ad.29.1732088807088; Tue, 19 Nov 2024 23:46:47 -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 4/6] target/riscv: Check memory access to meet svukte rule Date: Wed, 20 Nov 2024 15:48:52 +0800 Message-Id: <20241120074854.1767780-5-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::634; envelope-from=fea.wang@sifive.com; helo=mail-pl1-x634.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: 1732088893275116600 Content-Type: text/plain; charset="utf-8" Follow the Svukte spec, do the memory access address checking 1. Include instruction fetches or explicit memory accesses 2. System run in effective privilege U or VU 3. Check senvcfg[UKTE] being set, or hstatus[HUKTE] being set if instruction is HLV, HLVX, HSV and execute from U mode to VU mode 4. Depend on Sv39 and check virtual addresses bit[SXLEN-1] 5. Raises a page-fault exception corresponding to the original access type. Ref: https://github.com/riscv/riscv-isa-manual/pull/1564/files Signed-off-by: Frank Chang Signed-off-by: Fea.Wang Signed-off-by: Daniel Henrique Barboza Reviewed-by: Jim Shu Reviewed-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis --- target/riscv/cpu_helper.c | 55 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 0a3ead69ea..edb106b8a0 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -857,6 +857,55 @@ static int get_physical_address_pmp(CPURISCVState *env= , int *prot, hwaddr addr, return TRANSLATE_SUCCESS; } =20 +/* Returns 'true' if a svukte address check is needed */ +static bool do_svukte_check(CPURISCVState *env, bool first_stage, + int mode, bool virt) +{ + /* Svukte extension depends on Sv39. */ + if (!(env_archcpu(env)->cfg.ext_svukte || + !first_stage || + VM_1_10_SV39 !=3D get_field(env->satp, SATP64_MODE))) { + return false; + } + + /* + * Check hstatus.HUKTE if the effective mode is switched to VU-mode by + * executing HLV/HLVX/HSV in U-mode. + * For other cases, check senvcfg.UKTE. + */ + if (env->priv =3D=3D PRV_U && !env->virt_enabled && virt) { + if (!get_field(env->hstatus, HSTATUS_HUKTE)) { + return false; + } + } else if (!get_field(env->senvcfg, SENVCFG_UKTE)) { + return false; + } + + /* + * Svukte extension is qualified only in U or VU-mode. + * + * Effective mode can be switched to U or VU-mode by: + * - M-mode + mstatus.MPRV=3D1 + mstatus.MPP=3DU-mode. + * - Execute HLV/HLVX/HSV from HS-mode + hstatus.SPVP=3D0. + * - U-mode. + * - VU-mode. + * - Execute HLV/HLVX/HSV from U-mode + hstatus.HU=3D1. + */ + if (mode !=3D PRV_U) { + return false; + } + + return true; +} + +static bool check_svukte_addr(CPURISCVState *env, vaddr addr) +{ + /* svukte extension excludes RV32 */ + uint32_t sxlen =3D 32 * riscv_cpu_sxl(env); + uint64_t high_bit =3D addr & (1UL << (sxlen - 1)); + return !high_bit; +} + /* * get_physical_address - get the physical address for this virtual address * @@ -894,6 +943,7 @@ static int get_physical_address(CPURISCVState *env, hwa= ddr *physical, MemTxResult res; MemTxAttrs attrs =3D MEMTXATTRS_UNSPECIFIED; int mode =3D mmuidx_priv(mmu_idx); + bool virt =3D mmuidx_2stage(mmu_idx); bool use_background =3D false; hwaddr ppn; int napot_bits =3D 0; @@ -901,6 +951,11 @@ static int get_physical_address(CPURISCVState *env, hw= addr *physical, bool is_sstack_idx =3D ((mmu_idx & MMU_IDX_SS_WRITE) =3D=3D MMU_IDX_SS= _WRITE); bool sstack_page =3D false; =20 + if (do_svukte_check(env, first_stage, mode, virt) && + !check_svukte_addr(env, addr)) { + return TRANSLATE_FAIL; + } + /* * Check if we should use the background registers for the two * stage translation. We don't need to check if we actually need --=20 2.34.1 From nobody Sat Nov 23 15:26:32 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=1732088899; cv=none; d=zohomail.com; s=zohoarc; b=HQEwu10lBuWDUIdiT2O82d1JNz1rCONSNZBCzqoktv3HbdIHj2hdp5KNaFRSsITj1RFs3//v+C1PFdP23onTNaVMSi+kcRefUXK/FTQamKoKy6WG0leAzN+9l7YQEA2Ryc101x7GgGsW6oVZJJUv9f182ZtbaKD2TIqy8kWqsEA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732088899; 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=+R6CJpWjdehLs2i3GXP/SYVc9nAzma44ryk0pnQCtdQ=; b=Epjl667PSF4GIVunWIbn6pQUue2eho/3mEJocsxJ+Fy+VJyCLTaELVsB0qJHSppS3h9MjzEH2CbnucajOOYVuZubwmGkVpWhHtECS2CE9rHf7qUHdI0vUHSMoyuhm+fLGVpIqGRWXCk1gJuZQdf1GXhTNMiKjl/jRxLFz9ZEqeo= 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 1732088899545438.818428363271; Tue, 19 Nov 2024 23:48:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tDfQP-0002V8-FS; Wed, 20 Nov 2024 02:46:57 -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 1tDfQN-0002Tt-8V for qemu-devel@nongnu.org; Wed, 20 Nov 2024 02:46:55 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tDfQJ-0006RO-8e for qemu-devel@nongnu.org; Wed, 20 Nov 2024 02:46:55 -0500 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-20cdda5cfb6so47596565ad.3 for ; Tue, 19 Nov 2024 23:46:50 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2024 23:46:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1732088809; x=1732693609; 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=+R6CJpWjdehLs2i3GXP/SYVc9nAzma44ryk0pnQCtdQ=; b=nYTuI36SxaqsV0WIqZiHJmLYjaRpSmNphkBv4oKim28y0mXXRsvZc4BAvrPUISaI7F Zzj2pjTHbtkcV3cnD6ceOo+81ivFFXMGhXEH4gbSZeCzQph5sLR/uR8Cp1sz/m0dTXIs qzkDNVWlkfpoSQ3SVJ83b1vna0iXtg4MUCCO/JCDsY7KeiVm5UIg7NUOm2tNC7K3CIlK MNz0XBF9BP5JtommtLVhBjYlkMZWJFGvp0LQCVdJ4XcnOQ8gaeTMA8gMdjOgCEF314Xp yDW6ObRJHkHQyLTTN+jpHPnDubXxc/+dxrY6uT0K+4DLqrizGJo/hWWyxgaioecZE1kR EbwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732088809; x=1732693609; 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=+R6CJpWjdehLs2i3GXP/SYVc9nAzma44ryk0pnQCtdQ=; b=N7RsqvkJtKWA82aFn2HSMkLwDJctlxwy7gaiAcZpRMt6TP92fh2fzIyosrvKfkVcZg p3Iule6DhVOwSSR4EJSBFrs7F6/bEjPUPwQpmYj9+/mH2ccXJRr//KZ5AZqcgR9qIg7I ztZ8gug8tUme6zqzjgUSSkn80wYMvkhUg3du9p4fUENnqJJLRQZGIKEw/hmKqyt2Xm3I 4oZoPmJL+UiCPaBCe9aRFsRnpHy/liR9UDETyFTYlIGX4QRfCkp44pS/b5qcEvULNehu KKOYVbLF/FjSThXD+ZgyJSlkWzpsro+jx6dFjWTatcNrB/clQdYirYPYLrnhjC42aLlH UJCQ== X-Gm-Message-State: AOJu0Yxmv1RlCKZR6tCJFjl/vyKIbYLmkwAPhlzlJsHogpyxffMAm1IJ ysgJqD/addls9omzXuxObML1AIoaMsy9b1sP51M37e4JznCn2fjgwacHTsWi0pNWFOHIpMTInxT WH1G6eTDPprub1oOWcw3LNDZYIxYP+ALpsW26A9PCw14JPrqyqzg5A4URHDHG85yC91ARB9HRDo j17bRyzuRIqiywqWLi+6HGm/McbZViF5DDEmo= X-Google-Smtp-Source: AGHT+IHWMsNukUswGtL8YTBKYdPAr8BlKcsivdEBg7eYa5hUCD/qQnIhE8Z2bVDT9MO2AVC3gDZ+Cw== X-Received: by 2002:a17:902:e804:b0:20c:bbac:2013 with SMTP id d9443c01a7336-2126b04804dmr23848095ad.48.1732088809490; Tue, 19 Nov 2024 23:46:49 -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 5/6] target/riscv: Expose svukte ISA extension Date: Wed, 20 Nov 2024 15:48:53 +0800 Message-Id: <20241120074854.1767780-6-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::634; envelope-from=fea.wang@sifive.com; helo=mail-pl1-x634.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: 1732088901196116600 Content-Type: text/plain; charset="utf-8" Add "svukte" in the ISA string when svukte extension is enabled. Signed-off-by: Fea.Wang Reviewed-by: Frank Chang Reviewed-by: Jim Shu Reviewed-by: Alistair Francis --- target/riscv/cpu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index f219f0c3b5..6d3e9d563d 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -199,6 +199,7 @@ const RISCVIsaExtData isa_edata_arr[] =3D { ISA_EXT_DATA_ENTRY(svinval, PRIV_VERSION_1_12_0, ext_svinval), ISA_EXT_DATA_ENTRY(svnapot, PRIV_VERSION_1_12_0, ext_svnapot), ISA_EXT_DATA_ENTRY(svpbmt, PRIV_VERSION_1_12_0, ext_svpbmt), + ISA_EXT_DATA_ENTRY(svukte, PRIV_VERSION_1_13_0, ext_svukte), ISA_EXT_DATA_ENTRY(svvptc, PRIV_VERSION_1_13_0, ext_svvptc), ISA_EXT_DATA_ENTRY(xtheadba, PRIV_VERSION_1_11_0, ext_xtheadba), ISA_EXT_DATA_ENTRY(xtheadbb, PRIV_VERSION_1_11_0, ext_xtheadbb), @@ -1595,6 +1596,7 @@ const RISCVCPUMultiExtConfig riscv_cpu_vendor_exts[] = =3D { =20 /* These are experimental so mark with 'x-' */ const RISCVCPUMultiExtConfig riscv_cpu_experimental_exts[] =3D { + MULTI_EXT_CFG_BOOL("x-svukte", ext_svukte, false), DEFINE_PROP_END_OF_LIST(), }; =20 --=20 2.34.1 From nobody Sat Nov 23 15:26:32 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=1732088873; cv=none; d=zohomail.com; s=zohoarc; b=I7tteS4GIq6YjzN5HGixVKgjG9GqV3+SLnWspM1mwsRsYoL01rCh86SHeIR6lgf4N+U9+JfcdABsm/rlVQfHrXIOqp9ozdtARcruUzov/e1SdtHUCZBK3dgJwyi8Z7uEyHdT+aSOA2OYOhNj2zeVUlOwztAejrZ2GZrUDCAOWm0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732088873; 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=qR1sFxsLrriO/BPDZ7OAiWQXKRll1xzEwd9fI6XIvNU=; b=U3DpyH6NAmnO28z387H11HMnITbE9m4Zh+TCg2gOLh050JpPcs3+Bl5S3IJmTJIO0mLJYffdvcjheHPMDL0wmxGK7jQvQEv4zzV3UonQGiZBGHw12GH8XxjDIwiyd9MXSxAGea2m4Ub+E3yX0dKZREMIFpvQAP+AVM6/0m4tlcM= 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 173208887341062.54758641995909; Tue, 19 Nov 2024 23:47:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tDfQO-0002UB-1J; Wed, 20 Nov 2024 02:46:56 -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 1tDfQM-0002TZ-U3 for qemu-devel@nongnu.org; Wed, 20 Nov 2024 02:46:54 -0500 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tDfQL-0006Rz-Bl for qemu-devel@nongnu.org; Wed, 20 Nov 2024 02:46:54 -0500 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-20c7ee8fe6bso17380365ad.2 for ; Tue, 19 Nov 2024 23:46:53 -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.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2024 23:46:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1732088812; x=1732693612; 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=qR1sFxsLrriO/BPDZ7OAiWQXKRll1xzEwd9fI6XIvNU=; b=YkD+sP1bLXwlm4WQYEcTfmw67LJt0C4yflyejjk11T7wZ7YmLdxCjoTriMpW6YZyOm LWeCKcaJqSbEJ89X3yoRZJKmElfJrUhSIlpWfn5rSZbTXIkqYCkh/3jZ47Mm07p86Qh0 jYRD/39wcyaf1Is46fUEZ9BVbpH56EJeH5owLFMi4akRMchdNVOopYabCqY1nutncJ2l 9cMkW7BYJg69cXYu8xUningQRAXMruQ7k2kqrAURUCVSR8vvcwcnBJ/KJuSyWrqQpI3v ovo92WZ2VBcZaRn9rhiuUHNNXIehpJVbTV+xvmzJ9vqdQskvBXEG+YApbh5UZvWJBBSY EGYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732088812; x=1732693612; 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=qR1sFxsLrriO/BPDZ7OAiWQXKRll1xzEwd9fI6XIvNU=; b=l3dvVjuaqjjVK6iZflPDRw/UfDdqBJ5JOYgLmdnXBpQYDtHXfCYQscfOj95InC3jbr BC27t99hray1HvcQltFOAMJoR3aEG9onOdi4oTJrO8ct6upnhY4qOji2N0i4usLF+1M1 qDvU6gYkg8LsoIOs+kThi3bepC1NEutLxeMNkJ7ElyazsJE06Ear/e+HBugd1D5YKKvn DbSKhUI6/Xgp6PphjBULvwwrvdeypROWtAa0P1P/LtWM+7g8GI48GvD5QIM+0xLWDvF8 dHaxHkwS7WRuElEt1skX0eSaDSRZ7Oqxvzx6zxQ7fEG7NLN/fCtzpc7CkYd49ZGb/jAW YS8w== X-Gm-Message-State: AOJu0YztTzut4m4AMOnK7r73/P1SJ6ymQ0XL1D/H6C8C05efizEPppoU BGtLzgz9xL58V/P3QsRTeGe3XnJ6Heli/eoqyvB452pPYdO/Z5yQPRsGyq8yPNTztdEe7LMeH+V LR4ot/fGDIEUbQpLfnL+bQsK1cAkGPwt17DnwxZEL9H+ne5g74PZV5B95JQ061YdKnQfa0Lzqqa BlsI1HIyOkAhV163dF2OBwjWeVay+2tIA1Xio= X-Gm-Gg: ASbGncs3GDxMZgom824TDKoy/v6dU6dgt8iyp3kepB96jg4Sr6+dK5pFbJnRuqdHHm1 3ivg7L5zYd220fygTqz33gXFm+61MDJdGoCHz79myy+v/qaM3EXKIt7ViCOav/LeMZj2klsFtxF zKP4nMiNw73F1piNzulX6BmzC9Q35/uEB+JWzqoyaR91Uxso32o2QIWOb/laiHlPcuR1i2uOtG6 BpbujMKOGXgk9js1dNqqwxpka+ykacjPVZGpxyEMReb3Wy9E13JC75onGh+8Q4uIDqgrqATqUpN hzeCN7gvVobAXp0dkqFpUOfDn/BavLt8sNdgE2GwmA== X-Google-Smtp-Source: AGHT+IGcjC2zsB7038QVaycnOA00MoJQXwuwdXeTXVJA8GTE3hBHQdu5cZRc7+Qi8pQ4M4Est+tYKQ== X-Received: by 2002:a17:902:e74c:b0:212:1f:e66b with SMTP id d9443c01a7336-2126a474ee5mr16915655ad.51.1732088811665; Tue, 19 Nov 2024 23:46:51 -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" Subject: [PATCH v4 6/6] target/riscv: Check svukte is not enabled in RV32 Date: Wed, 20 Nov 2024 15:48:54 +0800 Message-Id: <20241120074854.1767780-7-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::62f; envelope-from=fea.wang@sifive.com; helo=mail-pl1-x62f.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: 1732088875151116600 Content-Type: text/plain; charset="utf-8" Based on the spec, svukte depends on SV39, so it should not be enabled in RV32. Signed-off-by: Fea.Wang --- target/riscv/tcg/tcg-cpu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index c62c221696..4273f1f472 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -652,6 +652,11 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, = Error **errp) return; } =20 + if (mcc->misa_mxl_max =3D=3D MXL_RV32 && cpu->cfg.ext_svukte) { + error_setg(errp, "svukte is not supported by to RV32"); + return; + } + /* * Disable isa extensions based on priv spec after we * validated and set everything we need. --=20 2.34.1