From patchwork Tue Dec 3 03:49:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fea Wang X-Patchwork-Id: 13891675 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 3B075E6C5F9 for ; Tue, 3 Dec 2024 03:38:55 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIJjq-0007u0-HD; Mon, 02 Dec 2024 22:38:15 -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 1tIJjn-0007tB-Nl for qemu-devel@nongnu.org; Mon, 02 Dec 2024 22:38:12 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tIJjl-0005Y8-PO for qemu-devel@nongnu.org; Mon, 02 Dec 2024 22:38:11 -0500 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-214d1c6d724so39179435ad.3 for ; Mon, 02 Dec 2024 19:38:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1733197088; x=1733801888; 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=h/QnCGqbZ4ThoW7K1Nl8vT60WyNjUJEjg+/j7OP8v+mLNxpNcTOrGNEovcAnB7tk+W yislWyPpL59anIJU/GNw+i4CWYe38+MVHJ+7C5MoMxk5L8K9B3XzsbFv2GKhGenk5zm/ bOEtlHh5ByzqqELfCFgpMDDpWwbs2ApnkcTE0W9fKorRt9X0lngNvTBzkwaLhAMnTcBD Av+QjUV1WU4AOcJMMPZ2sRHkOzbGHNYBhqdRcpGrY4UPgR/qCEn5M96znEuzNYYQfT8N p0dpYCvJdMSFYCxvamKR+0iCP7oNvIK7tcesO0HWNSWh0npjkUvBxkVFWb5l7pjsfFCp Zsig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733197088; x=1733801888; 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=ID21AnFdAwf04tG7llaznzD3dFhrNuqRyyBdoild2x2h7MGFIE8p50X5S3TD/FLma2 7QF3a1L4Mt+ZNqHzEoiVgebaZze/7YdGgCZtShuSGW8sDX41DXEciNXQsfau+E4Pawh/ HyYbYET/3cFmvIahCLPTiwV2ovUG+71R2AcWK1ept5IfhQsgU1Kq4VDp5doiwuBT1lPq JUKzqs0HWFnZS3BCYK7C9Oza2s3Zoj7RF2RkMrSlFZKGqcvOp5w3YhtAulkiKoYVhQoS 4MG4Npsbcj912cDDZSwU+ZDLnJ2IZ3KL6tmzL6LaqVewHndzMO0yXyWapqq1RWDQ21Hb LLnA== X-Gm-Message-State: AOJu0YwtycgCefydA0AIEO2QcydMmDc2SC9oeamRpvz7RWtZDf8uMKo3 ySjf1EnWJs0vE5jSig0z5jEubXPBsyvth8L/vz1aa2fzoXFcGP7tJYbxcNcZkOGeYdYQ/TgRqyW Ui8+Fq9lDMLRsWPYGI/HFuB+1L6cluToiuG5HkxUZ18HHoyJRkhcq79aqs6vHsYKgEZ9n8cf3CP P0yS9JVmvnWBLAZZispiGm9CT0950wsgMtMsHK5A== X-Gm-Gg: ASbGncuK2qjQMGqHgAKSQH/6NAGK3DGwaUC5fUc+IBnfSgHeDLkag3noj2nJaxXICQn cPw0oXb7CS+BxXw3fbeBT8i4zeYTRH1/pVbnSV9N22WTFLKi/HRyVLBYI/jIzzL4k0//kFCCXks x4JgXJn2q1UgKC7Qk8LdRdUnlKPqInLOS6G9FeWctDpgumFixlGn0kQXXxE0umAs7Guv9AZAzXA ZcLfH0xfCVghhXnsxeDMGjGQzPLgKLHftE45iVapaN+inIJagYAk6OIiVeioiuYgv0GoctnyNcg x+d3hnyT X-Google-Smtp-Source: AGHT+IEXojA/sOEDHW1MM7Nmm2rTZq6wRWPJN6Ug3GKxIkgNleZTZey3K35LdsgOa+hNLhFLHeH1Hw== X-Received: by 2002:a17:902:e747:b0:215:6afb:5b24 with SMTP id d9443c01a7336-215bd174cabmr11952405ad.48.1733197087714; Mon, 02 Dec 2024 19:38:07 -0800 (PST) Received: from hsinchu36-syssw02.internal.sifive.com ([210.176.154.34]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21566732e1fsm47111135ad.134.2024.12.02.19.38.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 19:38:07 -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 v5 1/6] target/riscv: Add svukte extension capability variable Date: Tue, 3 Dec 2024 11:49:27 +0800 Message-Id: <20241203034932.25185-2-fea.wang@sifive.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241203034932.25185-1-fea.wang@sifive.com> References: <20241203034932.25185-1-fea.wang@sifive.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=fea.wang@sifive.com; helo=mail-pl1-x62d.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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; From patchwork Tue Dec 3 03:49:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fea Wang X-Patchwork-Id: 13891678 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id EC88DE6C5F7 for ; Tue, 3 Dec 2024 03:39:49 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIJjw-0007vP-1S; Mon, 02 Dec 2024 22:38:20 -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 1tIJjp-0007tm-Nz for qemu-devel@nongnu.org; Mon, 02 Dec 2024 22:38:14 -0500 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tIJjo-0005Yd-6K for qemu-devel@nongnu.org; Mon, 02 Dec 2024 22:38:13 -0500 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-215348d1977so40017605ad.3 for ; Mon, 02 Dec 2024 19:38:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1733197090; x=1733801890; 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=XSD2keI6kr47uOikLztvd8QL4HxqBfs4yFVTlKypgaPGHZABn+Of3s2JEyShmRN/RM 3lNPYlDQBUtm5/iE14vYAUE5b5aoXx+oBaBdZtAfZKlU2JZTeqDif65/mc5VmI37OAt5 33SOPG5EzaPmeWZc6kXOAj4C+XgQ97bMoL9T+A9lop/o76Pj2wOy4z968Q9ILp0pNhdP sLUdYngB/54B/wyi6PAjLi+uFDdo/1wHSJk3SqWqWsOPGvm9gDx//DAeNWH11GOHWeW1 Gb4NAw0VBY0MNXP8tRzA6gUK/2TktTCsh9pTAwo03+20sDjCLP5+sqpOLPP1TVmcdD+V NVXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733197090; x=1733801890; 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=ncI6ctpjkAFxD70MIOHLFoSJsrcyiS9F3eZ17ZiJFLKX/d5CEPgxG8kgiFSXoUKMZ7 QAnzBMqHHFM2sTrh8OwaqGAt+CQkfzdFmjQgUvc+T8jbwAry7bZcS7WjF9WYC+M0TZCi 3ksA7i7sAQOgHvI3NvQ2TBwfKRm29Yrxn9VxGg4YBznuLArA/ke7lSGpSX9Zymk6SZ43 ZlIil7ctzVxmWo9d/S/3oK33+CJmWjM8S6gflAEmHySkX9grzpwMmH8qJMzd0LqZ4xDn hhqqiQwkAQvuVjkJy0sOsaTGOJ5WsXz2SE1twK63/z1bogYHdpJLyTIqptL474pIwIQk HXkA== X-Gm-Message-State: AOJu0YzjyywJ36sLn6VtqeUIerRa2I4EhShPxMsyAjuMnVpE9J47es+k SD2z4VS66Zp7SUUup5b80H1kdFlkPyXYc+R78DRd6nlQAnPoTppRTHCpHOspmjunstJ7fWys0MT stPfy+w4rumVjkVQdDYDhg2dD8H5j0u7vZ4U1ZXbdvcYe8W/+p9+UgHne+9s38OQnaY0FCq+8LL jIXvpPSeCj46AXm3SNCzMnKeUfjQPx70g7VYTuJA== X-Gm-Gg: ASbGnctHMyyPcx+oe6kTyRw67Kd6XVEFP71X8SwcnpVDL1Gz5gGMlUCD8DS/JwJUpcW pH3woB7XsoIexZwaPz/rTNjFjXJ/r2PKzqMLgtAH5OUJQR//zhjsYgl7qsrDmf/vuJV+pyXygWJ NBOQJiZWz0HcUKLuIQWX7DThKXe39lEb91j7OiNlGyOtO+Gdj3mMjw8Ijm8Se1Nw+ig/wUxG/74 QvaA1prO/WpdBB4vgQmJ4wl0V2JTyeShcOvOA8WHRNJ0AtLCqVwofBNu2DCU/8I2HYrI3EYvKG1 1dM4QW67 X-Google-Smtp-Source: AGHT+IEHtXViFXW4sYhOxB8QhRefysfVMSjU8kZGwY4fYluWkUledg/QrxI81ffPxr0nBGTmURXSDA== X-Received: by 2002:a17:902:d2c1:b0:215:9d58:6f35 with SMTP id d9443c01a7336-215bcfc536amr16677675ad.1.1733197090194; Mon, 02 Dec 2024 19:38:10 -0800 (PST) Received: from hsinchu36-syssw02.internal.sifive.com ([210.176.154.34]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21566732e1fsm47111135ad.134.2024.12.02.19.38.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 19:38:09 -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 v5 2/6] target/riscv: Support senvcfg[UKTE] bit when svukte extension is enabled Date: Tue, 3 Dec 2024 11:49:28 +0800 Message-Id: <20241203034932.25185-3-fea.wang@sifive.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241203034932.25185-1-fea.wang@sifive.com> References: <20241203034932.25185-1-fea.wang@sifive.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=fea.wang@sifive.com; helo=mail-pl1-x633.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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) #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 *env, int csrno, mask |= SENVCFG_SSE; } + if (env_archcpu(env)->cfg.ext_svukte) { + mask |= SENVCFG_UKTE; + } + env->senvcfg = (env->senvcfg & ~mask) | (val & mask); return RISCV_EXCP_NONE; } From patchwork Tue Dec 3 03:49:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fea Wang X-Patchwork-Id: 13891680 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id D4B0DE6C5F8 for ; Tue, 3 Dec 2024 03:39:59 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIJjw-0007vm-Hc; Mon, 02 Dec 2024 22:38:20 -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 1tIJjs-0007uO-14 for qemu-devel@nongnu.org; Mon, 02 Dec 2024 22:38:16 -0500 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tIJjq-0005ZI-Kp for qemu-devel@nongnu.org; Mon, 02 Dec 2024 22:38:15 -0500 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-2155e9dcbe7so24244535ad.3 for ; Mon, 02 Dec 2024 19:38:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1733197093; x=1733801893; 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=QDAE1O0dDpKVq4cvf1mV/LzdDRHmk5PPueySCbKUdAW/GXbzDTsvutkPDDK3ZAf7AQ gqX10EZBapaPjM0bZL4rdqmzBXQQjzjbSTIr+7cr6BgtSLBTWG77K6kmZ6oVDRK55UWm jwpxYsRk5bSs7NOAfnXXEboWrIYeWsKqIYzuKjXP4s+Si1uwtxlXUzKRI4wNeJZbCS/P GrROSnbaJApi9mX0Vl8ywSARnFUqjFSDfYMd/IBC+7Zbf4UyiVEa0UMyXz6wCWSXF319 9k175qvVs7/rO3PMOVoLz29q99iFkDviKV9hBxPnkueTEteIzE1wEVYwfUzfwz0mHEjJ e9pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733197093; x=1733801893; 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=AP5UidQpgo22Ucdrs0X5XfQOdKgPDRRtXcmKq4uml49MfNp7CwgHfr7LhU8oSFJpaP yS49GLI7mIBeuudajss08+i6hdzriTopvX2q6A/VLWFts+QkwdKePRHSgCRJqHaAW3jO YTFXR5K7ISsXUmv2/eDCE0A5jOHE5t6zBsmcGDorzapCtKQJg+2L2dYk4DouOG/xUwGo Rny4jUR5GJXL4h+KggR7ndOpg5UB/k93qQDktYoz/JFGCKTVN7lnVmiFDYLn/cXwz910 yMh/ToTiuw6nXtxx2bHNA/u/USptVptOPbe8Tvl1IQr7ILNP45XWrxT20z4DySNmt8Bv MsWQ== X-Gm-Message-State: AOJu0YzHq2u22kk3o/ZUK9U7z0KXcys8kFqvFhqACziV7lWLn2zL6qRZ Gm+oa6uaddXfFTfOc8p6NGNSifq/Yr0X7Rhaue0ttQ1FwtrH6dspRQG2QzFyKWWcAhUwi3Aubjv 9PCwOFfciwTINM/xwfUAEmLeiJiXPdgLfJ+g1orBr0gxQG+g5cmKK89s28LecBWj3WZz2+h6I9R kcy7fUl13ox1yswOVwr3znDOE/3fB0D8G8BwaWLQ== X-Gm-Gg: ASbGnctV8oDpbsVXdenlc5EJF9T9w+sa9gGe7mld/rPd/rXgMRlcB32GIIwfX02T2wA rS+uPIrrQbFBLhYNFxay/u/9ShVbHNGjFLTrPM/pQQWf451MLq4M6v3fSGfDMwie2HB3uYgiT1Q ijKNYWiI35PFVtYcXBmAEQhOIdsPyla5Iwds1htENqh5gbN47Th+9gfuaOkGNobUmtYWyudhjkS vo9ao9eMrNakf0nDyXt/Wh4muYuNG1nAMJ9ptXUYkytlkJOfwXjaPEqWBI7O3jY6Q5v+Cgz5eAu noDHgOgJ X-Google-Smtp-Source: AGHT+IHpaOS9cboDFSY5Y/16u7ve+D0uAJDEf2oA2rE5fUix4UWLXiR1xTrhPy+n4vqW8uvZsFl2+A== X-Received: by 2002:a17:902:e841:b0:215:5310:abae with SMTP id d9443c01a7336-215bcfc3e31mr20175415ad.1.1733197092743; Mon, 02 Dec 2024 19:38:12 -0800 (PST) Received: from hsinchu36-syssw02.internal.sifive.com ([210.176.154.34]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21566732e1fsm47111135ad.134.2024.12.02.19.38.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 19:38:12 -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 v5 3/6] target/riscv: Support hstatus[HUKTE] bit when svukte extension is enabled Date: Tue, 3 Dec 2024 11:49:29 +0800 Message-Id: <20241203034932.25185-4-fea.wang@sifive.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241203034932.25185-1-fea.wang@sifive.com> References: <20241203034932.25185-1-fea.wang@sifive.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=fea.wang@sifive.com; helo=mail-pl1-x62d.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 #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 = val & (~HSTATUS_HUKTE); + } env->hstatus = val; if (riscv_cpu_mxl(env) != MXL_RV32 && get_field(val, HSTATUS_VSXL) != 2) { qemu_log_mask(LOG_UNIMP, From patchwork Tue Dec 3 03:49:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fea Wang X-Patchwork-Id: 13891679 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 1D4BFE6C5F8 for ; Tue, 3 Dec 2024 03:39:56 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIJjy-0007x7-Bz; Mon, 02 Dec 2024 22:38:22 -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 1tIJju-0007vO-Tr for qemu-devel@nongnu.org; Mon, 02 Dec 2024 22:38:19 -0500 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tIJjt-0005Zj-4u for qemu-devel@nongnu.org; Mon, 02 Dec 2024 22:38:18 -0500 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-724f383c5bfso3840794b3a.1 for ; Mon, 02 Dec 2024 19:38:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1733197095; x=1733801895; 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=3e3WI4iosSzHiwP41BBTJfjUZj6un22IUON5rwHeyqA=; b=GBpphTnQDHwMHepPk35GuhoBsjVZzDqu3Ew6IG0dERfdeP9Et52QLOx28C8AVrY9tA RfWqnvS5rhVM4TAbNr2aEAsoA55dS/KZmVWscVNphB3HoPJO65+0b2expHd+8c4Z97+2 ZmGXcHm3ebG4Ue8XKRqssfhfCejJmq/qT228+aS2A+ssaYkxRQj5cOjgNmHmzva07K2C QxEiJOA/35z1yawCW7xCcQ9V/tScZ49d9Wz8MhHqUVLkRGmaQTLO1gZa+9Q1oXeaLwnW sQtY10eaHcaD5EGkKlHiWY9YkJP+VPVUMxOwj9b+QTocBiaMA6BVfqP2kWsGBItzrwm9 mOEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733197095; x=1733801895; 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=3e3WI4iosSzHiwP41BBTJfjUZj6un22IUON5rwHeyqA=; b=cnsZDE7qEaLDB3a+cQMbZMpJg92yNyoBX/j8MQglshDRIhEXRti4HkqBrPtV6pIGYs OUM3XmUT6KLf2o6V8vEDVSwdpA/D4uvV8PLKbkdrj5kkr/eZYH08B8e12PH5f8DUd5UL evoMWKrcL1evGJNBzUgvnzFG3D2q4fmzck0YJexJd1XdRDR/jo5itrpUP4CPNlAay6Xj 8Y07C9imTzkAfHUU6G5zQTh/9QPrX6wYMgPtcmguU78XHv+qfHZej+on0eHnnphqqQJ2 gM6qc1uyxj+AA6kiSvzir6flJR9br71cmG3MXF4b4XsgdNY35lvshX5qIKK7MCt3+8OE R4dg== X-Gm-Message-State: AOJu0Yzfr2goRe+UgfQdIGkhF8ObLJnCHJjkEShReoPNCb+zTxaK2rsI Y1sAmMoq/uDHPFBzWAjVREQWXdGY7mrWUQqtezcKRiXV9BiH6w1ySfKeDoiv/JM7AnC9FkH4VIQ KETzzlKwSZUUQkpAP245MHAdTmhOpdfiB9nttBOch+BTsZ2eQM/9+eKkD8sEYcisHe6bAN3CukT yl3FG0b8QFDwsDTdAmmUTZsDEgZgdeh4PrFWOQvw== X-Gm-Gg: ASbGncvYT2Sz9taukEuOvtmgFg7zsTPI9qNy5i31fBvv9mOrTD0o7PUZrajHk54sK7J f4EGKv3YhZzdycMlXlfmGROsJE2M7ckLdNCLiQ6N+WaFzVPWBTSkIPIZ+x16mbFvHy2YTKlmsx7 WwBBRtN52AbbshQMvZiDAAaUTYhwdaL3MmwzWVYwLmEjSmUnPDSL+lugWDkPFjjvMHD5NKYI7bY oVLqtA1D/xIw/09jfl9AHD/6I5mt3Wte/I9R+M1lkj8MIHwIBttoU1AtLQ4gRtDlR64q5DTlhht Cs9yxn6Z X-Google-Smtp-Source: AGHT+IHChw8ilVuNDdZLO9KNu2E6zKuzK24BSJF48DrsU2UbYaXZ/ELE/scUEwE3aXg5/ImGVx/wkQ== X-Received: by 2002:a17:902:f642:b0:215:6816:632e with SMTP id d9443c01a7336-215bd13ca9emr18544585ad.48.1733197095259; Mon, 02 Dec 2024 19:38:15 -0800 (PST) Received: from hsinchu36-syssw02.internal.sifive.com ([210.176.154.34]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21566732e1fsm47111135ad.134.2024.12.02.19.38.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 19:38:14 -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 v5 4/6] target/riscv: Check memory access to meet svukte rule Date: Tue, 3 Dec 2024 11:49:30 +0800 Message-Id: <20241203034932.25185-5-fea.wang@sifive.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241203034932.25185-1-fea.wang@sifive.com> References: <20241203034932.25185-1-fea.wang@sifive.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=fea.wang@sifive.com; helo=mail-pf1-x42b.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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; } +/* 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 != 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 == 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=1 + mstatus.MPP=U-mode. + * - Execute HLV/HLVX/HSV from HS-mode + hstatus.SPVP=0. + * - U-mode. + * - VU-mode. + * - Execute HLV/HLVX/HSV from U-mode + hstatus.HU=1. + */ + if (mode != PRV_U) { + return false; + } + + return true; +} + +static bool check_svukte_addr(CPURISCVState *env, vaddr addr) +{ + /* svukte extension excludes RV32 */ + uint32_t sxlen = 32 * riscv_cpu_sxl(env); + uint64_t high_bit = 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, hwaddr *physical, MemTxResult res; MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED; int mode = mmuidx_priv(mmu_idx); + bool virt = mmuidx_2stage(mmu_idx); bool use_background = false; hwaddr ppn; int napot_bits = 0; @@ -901,6 +951,11 @@ static int get_physical_address(CPURISCVState *env, hwaddr *physical, bool is_sstack_idx = ((mmu_idx & MMU_IDX_SS_WRITE) == MMU_IDX_SS_WRITE); bool sstack_page = false; + 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 From patchwork Tue Dec 3 03:49:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fea Wang X-Patchwork-Id: 13891674 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 38D15E6C5F7 for ; Tue, 3 Dec 2024 03:38:55 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIJjz-0007xz-Vh; Mon, 02 Dec 2024 22:38:23 -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 1tIJjx-0007wX-Oy for qemu-devel@nongnu.org; Mon, 02 Dec 2024 22:38:21 -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 1tIJjv-0005a5-V4 for qemu-devel@nongnu.org; Mon, 02 Dec 2024 22:38:21 -0500 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-2156e078563so18085525ad.2 for ; Mon, 02 Dec 2024 19:38:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1733197098; x=1733801898; 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=zG3P8sWTJ54W6skoaY1t1xd3E7zmiL03Dx51lEImsvQ=; b=ENBVvGVswUdRG0iSOpaJmVkm5mKOZxJwVLTwr3MenoxxGi5Zi7QVAZdGyzI+SVRkTa Ys+3vbKAB5H2vFNMPupuWXJVIfiWF8/8goJPoRcIQ5AwIkRbtqL6EchACEMafaRDENJy 1BT6/pIVy+7L94QY621mhlhHxhMUyXd8zT6srxppH+j+lPmVNbEkX/l0JJoyBZ9jPcaZ JDbKKVlXld0KZeNFF+cJi964fIfM4QaTdNWnFNv476LEkTgG4WMawmh+S7Udo9jV9Kxw ln+CLHbCqU5/3bw9raov69F8x39MaUGvnfDo0vjftMLCi/T5sDLSRcWmrhscTSMBqmSm 5Oyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733197098; x=1733801898; 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=zG3P8sWTJ54W6skoaY1t1xd3E7zmiL03Dx51lEImsvQ=; b=sTjgXW6vJqB8b8J+A7RFccRgxPZaiMxgAHE2/TT8fPeusVDskDIHMLMv5ALtvRhJ+R oRmGZzqEo6r4GpfBzHDC5wDdgIZAKxpROjTVDLJocyykb2vWIGWdLZOxaBTwz+eTMua8 /kkyfTwOTB5UmSwXmZrrakmc01LFj13fUlMi8XNxVlJ2R3pYGs8UoVdFep+rBai5HSZA UfiQ4jj2p6QELYSEngsoQoZUx0Efhl51DdT8JcYmdOq9klDvjbRhv2qN6uzpI4ut0Tzx B6onaeuq2v5FJWbACTh0dZZAAhj6amhVcVh6F07yRggtr4AbeQUk863RJf7gQqhWmd2C qOpw== X-Gm-Message-State: AOJu0YwBH0ZekvJFyj7/KApFUG8aIvp2Wv9UYkoOaK1wtr04lOarg7l8 AmkmL8xB9044Ux8Xe99HIgDQ1f6J48b+b/R84U4QRff4WmxsN5G+HYK1MZZRsHx9BdyAMdmMutP 85VLU8QUkVskYMzIFwPp2kdxQ0zDD1xlruIeTRZI9hxwDm4CPomBXOcF1JEU07vuI2lw1j/r2an uYHCpnJW/vFN6J2/UoS18eISpOpkQB5hfh5JCRSA== X-Gm-Gg: ASbGncvPD3d73h5f7mQ1P0asiFRihgEDoY9heOzgoiy1mZ4YnVrR09j6wK0V71MvAJL gCcT1EeyBFKYchXcKYmGlLKWpsesRed7LEfEVfOdEuhXCBguKkYpy3Zio2vSlUUJ+eflCVsIIG/ djMNYsr3XNS8GY0nyGFUaX4fCi8JfuQ7bqMk7acof7/kbm6buEPodLveNU54ZeV6DgdFamiY9va eJJxnjpkWQX6C9Su1vMu4CIus08meeAIIU27KfKjWPg/3kyc9oGMDEC3UUIgCEtk+dopZSYZS/L PBgLZoVz X-Google-Smtp-Source: AGHT+IEpV2YVstExh60DlC/JmmsYebJZFXHzs6amPgyrOb478bEiin5HHyYAmLyQOP8GqG7+TQlBVA== X-Received: by 2002:a17:902:db06:b0:215:7dbf:f3de with SMTP id d9443c01a7336-215bd2005a9mr14010545ad.28.1733197097796; Mon, 02 Dec 2024 19:38:17 -0800 (PST) Received: from hsinchu36-syssw02.internal.sifive.com ([210.176.154.34]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21566732e1fsm47111135ad.134.2024.12.02.19.38.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 19:38:17 -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 v5 5/6] target/riscv: Expose svukte ISA extension Date: Tue, 3 Dec 2024 11:49:31 +0800 Message-Id: <20241203034932.25185-6-fea.wang@sifive.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241203034932.25185-1-fea.wang@sifive.com> References: <20241203034932.25185-1-fea.wang@sifive.com> MIME-Version: 1.0 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=ham 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 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 8447ad0dfb..e10240c02a 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -199,6 +199,7 @@ const RISCVIsaExtData isa_edata_arr[] = { 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), @@ -1661,6 +1662,7 @@ const RISCVCPUMultiExtConfig riscv_cpu_vendor_exts[] = { /* These are experimental so mark with 'x-' */ const RISCVCPUMultiExtConfig riscv_cpu_experimental_exts[] = { + MULTI_EXT_CFG_BOOL("x-svukte", ext_svukte, false), DEFINE_PROP_END_OF_LIST(), }; From patchwork Tue Dec 3 03:49:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fea Wang X-Patchwork-Id: 13891677 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 030C7E6C5F7 for ; Tue, 3 Dec 2024 03:39:03 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIJk2-0007yj-7s; Mon, 02 Dec 2024 22:38:26 -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 1tIJjz-0007y0-UD for qemu-devel@nongnu.org; Mon, 02 Dec 2024 22:38:23 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tIJjy-0005ar-GM for qemu-devel@nongnu.org; Mon, 02 Dec 2024 22:38:23 -0500 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-215b13e9ccbso9768685ad.0 for ; Mon, 02 Dec 2024 19:38:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1733197101; x=1733801901; 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=6+unVT0iJ51qHfPa5G/FCD6L8b3hBokRmjj3mo3WsF0=; b=XVLMS7SBUPWYQbdoiCxUCRb3t/5uQtjRr1kqj9lTWXqVjuiX07V7B7Y4OoHTwGcPuG Cw07FznL06sHkc+nIM+7AlFq6KRn0eRNc3Jm86NSCmsgUUqARZjXVo7G/D9sVS4qDkuJ 4Fs/mOdH6yoU/9/YumXw5EnmpxVSetkaJyjwJ6d9hRpfhy04h5clV1zmaYcPG4ARehtz YR4nm8zsswya3XdctCVOzikxYb634yA/EMzh35j8bUYgEHvgTLnuKpeNqKW6HFaFjM+j LhsFTUb80rcae7279cdrqX4WDDwMNLc0pEWuHZNrqHtyQQYMTwt9+cghDshM79L+9+yC XSWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733197101; x=1733801901; 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=6+unVT0iJ51qHfPa5G/FCD6L8b3hBokRmjj3mo3WsF0=; b=vR4mvuqhQX1Bq717nkfJl5WTg2Ycdjx61QhJClOa1HLhGOwWTsKpRN9L26TpVD+NwX E+2BK713pX4KlsVyyM0QRCreNb9v5yNtL5ug/M/cvlcsBzoobnMwkjfoyv5QkJW9SmTO e6oyhLdIeabCLyiJD1fIv5mxbPKe+x2K+kiTHH3PIP2xMGycSw3YlfWbauxod0QvdHwL j/jDsGYyuRNIHw7tJIzMGUCksqOFoRrCGvO4rS5Xv0OZoZuGJ0HqA58VGzJCZn2aMMH1 9okDrePpF1vgByhlaaKwEiQ1PkZNrP2xljd+CxNXZUh0V2kXnnAXpmScKSPg7r1aIaCp Co8A== X-Gm-Message-State: AOJu0YwiqPtee7qC0Wrk410ZC1EpMeIEwdhDYZSqefp2hkUIB+6Ca12Y O5Zt26ViqTqV7mSWb7UBzPOqp9HUEPjZSl2oV9jmgOHH94AsnbWQ01O1RT7aDSHK1gzJXY4/MPz ytrHcjR9y4KsiBDdt/0lmvnowfFC+eqKfUeYAWDGY8o5G1ZBkVVa6nPc9mZ93h2ikNtYK8y1XrX e1rDHSHD7UMCTxkHeObylvAcDcZ3DEC9fnsI5hEA== X-Gm-Gg: ASbGncvgcC9ErqwaRP9tjvxVGWsw+dnn1dP3oBmQy98yIGC/pulXdz9R7fnxrZB5acJ ZWhv2Pm9bOv7N+cT8pJvvaAb4kzTRZf0hInutiD5rkHY5TbOiZqhQTIt6rkabDKcteMlp1xZd9/ vQbQaggUeBAxaGs3B/xSq4VSOptEPuU4bBjo53owA/mRgVKzijCDVBosL1VvQilWxVDFw4exVmR o0gvv3hP//bD8GSqLebYvZ5/noDEruCQFUFh4LR2ZjiGfffL1AuawrfrHJZo1Y7QCMMYfnB3h/y lFCBtRiy X-Google-Smtp-Source: AGHT+IF54AoRZSJTTdV3rrBFyBeOMkXnmI3hPNSBNW1iG7cEI8X5C1ycKaeDLOBAh+umz6H6YnODQQ== X-Received: by 2002:a17:903:2310:b0:215:58f0:2606 with SMTP id d9443c01a7336-215bcfbce9amr15371325ad.2.1733197100285; Mon, 02 Dec 2024 19:38:20 -0800 (PST) Received: from hsinchu36-syssw02.internal.sifive.com ([210.176.154.34]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21566732e1fsm47111135ad.134.2024.12.02.19.38.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2024 19:38:19 -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 v5 6/6] target/riscv: Check svukte is not enabled in RV32 Date: Tue, 3 Dec 2024 11:49:32 +0800 Message-Id: <20241203034932.25185-7-fea.wang@sifive.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241203034932.25185-1-fea.wang@sifive.com> References: <20241203034932.25185-1-fea.wang@sifive.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=fea.wang@sifive.com; helo=mail-pl1-x629.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The spec explicitly says svukte doesn't support RV32. So check that it is not enabled in RV32. Signed-off-by: Fea.Wang Reviewed-by: Alistair Francis --- 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..3b99c8c9e3 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; } + if (mcc->misa_mxl_max == MXL_RV32 && cpu->cfg.ext_svukte) { + error_setg(errp, "svukte is not supported for RV32"); + return; + } + /* * Disable isa extensions based on priv spec after we * validated and set everything we need.