From nobody Thu Sep 19 00:15:13 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1721268993; cv=none; d=zohomail.com; s=zohoarc; b=JkMV9gh35aGj0XnhhF+eMYmL3J+ZW5BZrHKqH2dvnLizVePh8b/Iy5QTGKP6oxi6BW8ni8I2g/uvHdnsUw+dSOoJMOKGCP2KW3KhVxCLOpDcPWNgt9+HmIjGwhAi4942i71ynLGuTkL7HNm6GVVged8+xmnDUliBkW5+dH94gh4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721268993; 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=MURTYc3GhQ8xUvt5I/QPqguLyHcGs+Rdgu0cao83RwY=; b=Snl2agocE9J4Whm9ozeJBicMBP1hImedGZSJHT9ykupUAV+YQDJ0LRq+NdiQgJKB4ifTjrGO/4Cc4ujBeNVu7+Pia+DmMWpUU5K2Z0X8pOpbf+fUIJz4hu5lJSkALc+WLkDEx6btip/2pvPHnsC39icqNYRQUumwCYnBeO/apJ4= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172126899362591.50438428269763; Wed, 17 Jul 2024 19:16:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUGbq-0006CA-0n; Wed, 17 Jul 2024 22:11:06 -0400 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 1sUGbm-000628-U6 for qemu-devel@nongnu.org; Wed, 17 Jul 2024 22:11:03 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUGbl-0003SM-4O for qemu-devel@nongnu.org; Wed, 17 Jul 2024 22:11:02 -0400 Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-79b530ba612so84887a12.2 for ; Wed, 17 Jul 2024 19:11:00 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fc0bba949bsm81999385ad.69.2024.07.17.19.10.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jul 2024 19:10:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721268659; x=1721873459; 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=MURTYc3GhQ8xUvt5I/QPqguLyHcGs+Rdgu0cao83RwY=; b=Pi4dwaa8o5ey8qiv15wReG+IAzV27kUNE4e62lSHn2hiypv2h0ASf30sUpK7y8wB1F MsncYK6cFLwAgQFJIUMu6B87e3EgK2Hqb2xQpf4tI62nvl1Y47GvMQWa7nRq6qgz0MUL 0hsNfTv/2aLTCllwD8RThYu6cnngO60RzlJCT98DmhEtV14CihMy4g5FmfCBvK/Yc8kd td+sdYDWayfI66jtNU5kqaQONPl9b5HlR4+4ds9NoEjboxv1Z5EbGLkgy3mPSJFrublN 5BX7AFxe7am3xxBG9b6MuqxAFRgaxfm9pJ0QOs65q9KQ7aCZ8QXoNHSBIP/siXR1l0/z L+zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721268659; x=1721873459; 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=MURTYc3GhQ8xUvt5I/QPqguLyHcGs+Rdgu0cao83RwY=; b=MYOuRLipgw9Uum6iQeR59tKpUW6dhsHwfnmNWhZzuUK3ZQiPOA72boFo1pK9t1S1KE uur2Ac0NVFLxivcIPhOfTDsX4DD92yJ9rsXpuGju/DCXnoidEjAcww0iA5yY3i6L/3AW 1Tc7X4f1u92qNvfdwJjfN6vVyvSw9j7bSMnovSdnYIx3Kb6k2Bc3A1sgv5NlAfEP0cRl FB99rB4hMNtw/MGLpR30wX+gyYFX9TkENconIMK7w+ovgT2JkznT8bNic7DGOUcXUSrL zm6tKVlGE6b+AWqu/NpH8uJLobsFWdhHsxxStcCSf+4WWEa8zMMFcktCYzEIG6HF4wEY mVYQ== X-Gm-Message-State: AOJu0Yw0QjOO4vXYaA2OdaQgtY6cbwsdLSSKIj4xSu2WWpfE4kXWHg8w 5zu/PYgHb8nVt51zYXs64Iij6IVuBkNywx8zpRpX+5oVg82+vjkdC/+/EKYh X-Google-Smtp-Source: AGHT+IFZVuk1F8xbeETAKA4bOc3Z9OEy8NQTfWp0MjpiKC+RE9sg7yLzNd33gZHTL0kh7VjVBa6BSQ== X-Received: by 2002:a05:6a21:6f02:b0:1c0:f1c9:6835 with SMTP id adf61e73a8af0-1c3fddcd3abmr4196102637.51.1721268659369; Wed, 17 Jul 2024 19:10:59 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Jiayi Li , Alistair Francis , LIU Zhiwei Subject: [PULL 12/30] target/riscv: Validate the mode in write_vstvec Date: Thu, 18 Jul 2024 12:09:54 +1000 Message-ID: <20240718021012.2057986-13-alistair.francis@wdc.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240718021012.2057986-1-alistair.francis@wdc.com> References: <20240718021012.2057986-1-alistair.francis@wdc.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::52d; envelope-from=alistair23@gmail.com; helo=mail-pg1-x52d.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1721268993818116600 Content-Type: text/plain; charset="utf-8" From: Jiayi Li Base on the riscv-privileged spec, vstvec substitutes for the usual stvec. Therefore, the encoding of the MODE should also be restricted to 0 and 1. Signed-off-by: Jiayi Li Reviewed-by: Alistair Francis Reviewed-by: LIU Zhiwei Message-ID: <20240701022553.1982-1-lijiayi@eswincomputing.com> Signed-off-by: Alistair Francis --- target/riscv/csr.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 432c59dc66..f9229d92ab 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -3791,7 +3791,12 @@ static RISCVException read_vstvec(CPURISCVState *env= , int csrno, static RISCVException write_vstvec(CPURISCVState *env, int csrno, target_ulong val) { - env->vstvec =3D val; + /* bits [1:0] encode mode; 0 =3D direct, 1 =3D vectored, 2 >=3D reserv= ed */ + if ((val & 3) < 2) { + env->vstvec =3D val; + } else { + qemu_log_mask(LOG_UNIMP, "CSR_VSTVEC: reserved mode not supported\= n"); + } return RISCV_EXCP_NONE; } =20 --=20 2.45.2