From nobody Thu Nov 28 07:57:11 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=1694153210; cv=none; d=zohomail.com; s=zohoarc; b=BZchJf+x3lLMcKt1O+9inD5cBjemR/t8yZxPIR0nK+mTUqVe0n6tqhLLPTriEbbqm4EtoXMmuNdMoiJL0TBjkwAJ+ujcjLwSC75quLeFhjx8zy9SR6VfVHs1AUNzBfhOv5stFfCRLng2eoACUl/9hxtAVxxfJZKsXp5YM7LxD4I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153210; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2hidEe0WK9qfQspdXyERizbv/cOtqOtrvyLGVTGCseA=; b=E0TH1duITDp6VxY5UrEzB9I5o6DOxKiPIpx3VCaswK5dTSBJBZ8S6gnotnEfKW9fO9OrUgCrkt+TGInrwPSQJeyvzVpwT1aSZTJABcjCvWZnGnxADqz0M6OKNdcnYNxfxjgmKQjsZc3FNs8vL6WHrLzAyD04juv9t9VIHWVRizk= 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 169415321096225.43833374170231; Thu, 7 Sep 2023 23:06:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUc4-0008Th-Ot; Fri, 08 Sep 2023 02:05:04 -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 1qeUc3-0008TP-6h for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:05:03 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUc0-0005Bq-RJ for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:05:02 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1bdc19b782aso13611965ad.0 for ; Thu, 07 Sep 2023 23:05:00 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.04.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:04:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153098; x=1694757898; 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=2hidEe0WK9qfQspdXyERizbv/cOtqOtrvyLGVTGCseA=; b=fj+4PRe0FU3iPcgsCfEtjudlUPvk+gWUgVr9Qz6rIaH9zEWM9NUKrEjg0wZGYoqLYD gsrA+NEtt55FN3Ov/xV2bTO1y7FxYb2BZlm5r8KsDczSggOkv/6RzBAIP4OiJGGGu/LH 3srHh1S1My5ZYude/sEh0cdME7fpbtZU3+S7B8NLYyWHDBZ/OUkyhyZ/Joaso4ixizxi +D7VJDRNigPEC4KzTL78nRH+AEBToa8NWrfwkLX+azSofWoD2f+N8BhiUxPoEqPxq6W/ md+7Ox8SLcVJb691C/of5QRGtI7QjQFXfzPAn5yIghSuiHxt+nslleWld0/EixzBAG7r Ba7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153098; x=1694757898; 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=2hidEe0WK9qfQspdXyERizbv/cOtqOtrvyLGVTGCseA=; b=ZISVXjvVZCWc2D0bF4AxDb/7IYhRROGfzTKXr+NEU9H0ConqVDESfhSbrmoFVwajzP PwwH85vNfRLvXozdNmNeHkS8ZJnklbIM/Q+qnz84P/BvAKp9hxTp6ujE6M1Zm28xRld0 YwcKkBVmd/FCEHlbp6f7XuYlqAWL49+yoyMz7pOkPxWTDOGQZjGQfAzvrA1geMocgmCz LZqh1yti5nANivYfMJ3RNnJXab86fyI7VHu7F3qUyHdetu9nBZBUjHs9wy0yJFzIFx3X 89KGGdsYhII7sfSq+zogQgeWV5bg4hIZIfPtQz5x9L6CH44OlDAdpd/hh+nB146F2bS4 dtGA== X-Gm-Message-State: AOJu0YzXVVT0z39zjtJdEwvyX6I1gAp1X3MexgBHw6x8pp/0Q5LSZl5h r4ruysNvjFVecm9viFZqqUlIOxaGCDQaxb59 X-Google-Smtp-Source: AGHT+IHwGvUfBUdMRFfhdkEpK8o54jeDQaliV7/D4GV5bzoNhnW6PrRbsi1Jhhl9CJ1i0Vbxt9tKDg== X-Received: by 2002:a17:903:1cf:b0:1b9:e8a5:3699 with SMTP id e15-20020a17090301cf00b001b9e8a53699mr1744875plh.21.1694153098545; Thu, 07 Sep 2023 23:04:58 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 01/65] target/riscv/cpu.c: do not run 'host' CPU with TCG Date: Fri, 8 Sep 2023 16:03:27 +1000 Message-ID: <20230908060431.1903919-2-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::635; envelope-from=alistair23@gmail.com; helo=mail-pl1-x635.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: 1694153211968100002 From: Daniel Henrique Barboza The 'host' CPU is available in a CONFIG_KVM build and it's currently available for all accels, but is a KVM only CPU. This means that in a RISC-V KVM capable host we can do things like this: $ ./build/qemu-system-riscv64 -M virt,accel=3Dtcg -cpu host --nographic qemu-system-riscv64: H extension requires priv spec 1.12.0 This CPU does not have a priv spec because we don't filter its extensions via priv spec. We shouldn't be reaching riscv_cpu_realize_tcg() at all with the 'host' CPU. We don't have a way to filter the 'host' CPU out of the available CPU options (-cpu help) if the build includes both KVM and TCG. What we can do is to error out during riscv_cpu_realize_tcg() if the user chooses the 'host' CPU with accel=3Dtcg: $ ./build/qemu-system-riscv64 -M virt,accel=3Dtcg -cpu host --nographic qemu-system-riscv64: 'host' CPU is not compatible with TCG acceleration Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20230721133411.474105-1-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 6b93b04453..08db3d613f 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1395,6 +1395,11 @@ static void riscv_cpu_realize_tcg(DeviceState *dev, = Error **errp) CPURISCVState *env =3D &cpu->env; Error *local_err =3D NULL; =20 + if (object_dynamic_cast(OBJECT(dev), TYPE_RISCV_CPU_HOST)) { + error_setg(errp, "'host' CPU is not compatible with TCG accelerati= on"); + return; + } + riscv_cpu_validate_misa_mxl(cpu, &local_err); if (local_err !=3D NULL) { error_propagate(errp, local_err); --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153145; cv=none; d=zohomail.com; s=zohoarc; b=fEcEl6Kw7yEAdz2q3yBS3RMxA0uTLhV6Z4+SpIPGrfyji1wZT0/mJPeQfTV2BLwUzrji9EBtrkqTlvkEF5yCgH+bvxSAbKSphhkQgwLABGYU8ASm6t3jXCztGzD45LRAgVFJWYRPHCJlKbl0oQo8Ta1BrEAkOLLp9o2qBDEAM9Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153145; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vym8XbbEH4MOTDPO5rs9mKsM5VAOMq/9GygQwXQnKYA=; b=D5Ksl+pzdvGstJksNhLX+BUq6dI+EGDTO3oh14YLtNl1ZWuCS6uoL0VwSCI6pvTNQSxYG+21hTChPjcxk9Wi3X8VA1dVRMXw0GiRJF41m5m9ply8NBzdeFFkE75qcyCooCXHqLEHUGRQq+T6iWQnh+Z/zlKKk5NP70vi74jf6Tk= 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 1694153145457232.16827263889775; Thu, 7 Sep 2023 23:05:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUcC-0008UO-Jb; Fri, 08 Sep 2023 02:05:12 -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 1qeUcA-0008UC-V8 for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:05:10 -0400 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 1qeUc5-0005Cc-E4 for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:05:10 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1c06f6f98c0so13935675ad.3 for ; Thu, 07 Sep 2023 23:05:03 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.04.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:05:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153102; x=1694757902; 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=vym8XbbEH4MOTDPO5rs9mKsM5VAOMq/9GygQwXQnKYA=; b=q4h78H6JYa4GmTloCCHNUeFmAcbIKMxI8dLBaISqZUFvWyCjWeR93tVQrKHRKwWQTW XQaWoEfiRURtYIari1HTxBl80jvGMaiDC2SjBP+ozdb9gbiGFJj+9pgey0DdORutWoJV Ic8gQ72MmSzF0Ge7wt5MStuNlHIhgodkdKH0Kah+MlZlmuKycvGuXrSc6iyhWOgaUqGt XLn0gUx59WDbOneeo+kH2n0WsQOrQoxoYF9MHDpLPP9Uc9cpJhpNKZT6Atxq6T7hXNfI z4H/JS8bTj9scbvqjF22g6j7KaRJsTN9UggYp1oT9qCyS9OyFZdGDnY1i36mF7V33m8O 9SwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153102; x=1694757902; 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=vym8XbbEH4MOTDPO5rs9mKsM5VAOMq/9GygQwXQnKYA=; b=C3W+ZqDjWs8eH3XzmdPe9x+qlRggeqnwzt9rVW0ijRB5/BgW8cGagLrZ6IUHnktkLU lu9cy0gooiO9NmwjhGQ4d5GbPuCL+kmI9sTooP7fUIg5ntvx1EEL5HlEtFKq+dIkI/+E U1fmq/OpCxzBgJ0KzhTojlDEYKqx83inKRn1S6SGaip+vOHaJBjRCYhFYSv2pGsvoOwr wixGeZGlFyFzr1xAXgg+fZOXCDcI96RdkFmM/dxt4siLOgj3bllZ/DdmpQeEJ4p3DqbD 2CtcdJcfIt1OdXAie+1pa8qRynHhqahOJqGiMnL04SWALcj0vUajTKWIB+//gl2T+39r Or8A== X-Gm-Message-State: AOJu0Yzd553z7B/usbs9uJcd0nbAT4V1XMw/SqEgDkQKThd4RrT288mC mzyzR9BPi4XCOt/r38zPsA4rmc5cF9diYBmx X-Google-Smtp-Source: AGHT+IGB0yKImZLaxrKAObiL4nhHCn950URu7udzeeMeJoUptMtO8xtMc3WQreNIBK+6/ixjYmN9lA== X-Received: by 2002:a17:902:f7cf:b0:1c3:6705:bcee with SMTP id h15-20020a170902f7cf00b001c36705bceemr1553292plw.57.1694153102512; Thu, 07 Sep 2023 23:05:02 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Thomas Huth , Alistair Francis , Bin Meng , Daniel Henrique Barboza , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 02/65] hw/char/riscv_htif: Fix printing of console characters on big endian hosts Date: Fri, 8 Sep 2023 16:03:28 +1000 Message-ID: <20230908060431.1903919-3-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=alistair23@gmail.com; helo=mail-pl1-x62f.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, T_SPF_TEMPERROR=0.01 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: 1694153148417100006 From: Thomas Huth The character that should be printed is stored in the 64 bit "payload" variable. The code currently tries to print it by taking the address of the variable and passing this pointer to qemu_chr_fe_write(). However, this only works on little endian hosts where the least significant bits are stored on the lowest address. To do this in a portable way, we have to store the value in an uint8_t variable instead. Fixes: 5033606780 ("RISC-V HTIF Console") Signed-off-by: Thomas Huth Reviewed-by: Alistair Francis Reviewed-by: Bin Meng Reviewed-by: Daniel Henrique Barboza Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20230721094720.902454-2-thuth@redhat.com> Signed-off-by: Alistair Francis --- hw/char/riscv_htif.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/char/riscv_htif.c b/hw/char/riscv_htif.c index 37d3ccc76b..f96df40124 100644 --- a/hw/char/riscv_htif.c +++ b/hw/char/riscv_htif.c @@ -232,7 +232,8 @@ static void htif_handle_tohost_write(HTIFState *s, uint= 64_t val_written) s->tohost =3D 0; /* clear to indicate we read */ return; } else if (cmd =3D=3D HTIF_CONSOLE_CMD_PUTC) { - qemu_chr_fe_write(&s->chr, (uint8_t *)&payload, 1); + uint8_t ch =3D (uint8_t)payload; + qemu_chr_fe_write(&s->chr, &ch, 1); resp =3D 0x100 | (uint8_t)payload; } else { qemu_log("HTIF device %d: unknown command\n", device); --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153185; cv=none; d=zohomail.com; s=zohoarc; b=m2RaNNT/YQxRTdYI6WYyMAbQ2cFBtkCuJBSzQbCbg9Dp2kgVQ8lDp//vrkaHxutJUOpHZ8Aeh4L+KmlM/zYOGNqyNLmPgaWYJog3hhTTyXonm8vyUpRLHEu6U/gJxS3o/JMvLu+WDq+RTImtnq2HpEPrQ6jzrfQaXHDQpGiHxVs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153185; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TjdxtVU3gNPjJmXFfAVRml366UxrtlzbUcZBrAyMCEU=; b=QATravVMg+rYzFLPNikca59fmQy7sn1mKE2DhKCYVv86zuoLTzgSZqS1eRb9dIxnZlYj3nNq8ftAfdurFN2ucu+DO/sGc7AbOsI/aNepyWTJdMNwonaxBAPa/MhUkEFYQYfKhN2invOpWsX0FEcRnqpbNnjF2ey6y3aCQLlAPDg= 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 169415318560939.64279378735057; Thu, 7 Sep 2023 23:06:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUcD-0008WG-2z; Fri, 08 Sep 2023 02:05:13 -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 1qeUcA-0008U8-Om for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:05:10 -0400 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 1qeUc8-0005D0-De for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:05:10 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1bee82fad0fso14660955ad.2 for ; Thu, 07 Sep 2023 23:05:08 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.05.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:05:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153106; x=1694757906; 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=TjdxtVU3gNPjJmXFfAVRml366UxrtlzbUcZBrAyMCEU=; b=qhwY4i2v7M5r8EGe7TlfQy6Ssv8xoBoaXxjOznFW66cYc7WYWJWtobtdag400mwqXj t8f4Ihgy5xeueHmcM6dRsBWx3uHDyhIcNysmOdiUydWRk8zjqThWiL0TxNf2ZcVMqgf2 q45fEjM/i59opjah3m8PbBaEhtkiFvwyWFP/q+lrWST+KAUqqP5hUsxQNFkmXnybjDJI 4df9wtzPpYgwEuz725UW4w3co6XszIS2bAEsZ2j0RfTAb+voq4Xse6iQR5KrDBdGTKXO u+MIJWZ624Rad0If3hwh1otRz1D4RPVpw/4Wc2Gb8gbF/y/PhA00X4rAF5Fd8PH3HLj0 l7rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153106; x=1694757906; 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=TjdxtVU3gNPjJmXFfAVRml366UxrtlzbUcZBrAyMCEU=; b=dMDW8IM7S7BuZZhg3W3OxsjqiOcquKVf0jqaMJk3B0oF8hCG06JRg6pl3ZcWn6icws HcV/YhopMCnFDXDtu3CxC0xzrjcluVprGcXJFrYnpE6swN6NTFnj8meI6g6A1V0CPBWu ZnUdoPKW2y0gQt/iO3aeYJf7GA/E4PZoacrLrHx012c3RKf6lHX6+fTtZmDn1Jl9qPkb QkqVnr8i0RXIthMaP9wcER+kFFqO8Mp3KpKBkTOpo1Uzw9S6RJWETDByQiy/qMWxhheQ 70zm0h/YXXiLHpzNdMkupZt9QvbsTh9g/QnhaNgpbqQge2O348GVOm5/ZSUbFz2SQcvV 8M+Q== X-Gm-Message-State: AOJu0YxIMw4j4lJ3NO1LaHrv9RauIQhAT/y9sj5dOca53b4/9WnHDRa1 6ZEx2wjejKDg20HUYAXZxoWdkQpyzYYNhL69 X-Google-Smtp-Source: AGHT+IEJBxij3UDeLb5QsG+N4+0qrKv4inB0P1Mm8zVbOa+U1yTXE31lF0UQyRCbxrOvUrCyGAZ/ew== X-Received: by 2002:a17:902:b497:b0:1c3:61d9:2b32 with SMTP id y23-20020a170902b49700b001c361d92b32mr1399375plr.45.1694153106453; Thu, 07 Sep 2023 23:05:06 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Thomas Huth , Alistair Francis , Bin Meng , Daniel Henrique Barboza Subject: [PULL 03/65] hw/char/riscv_htif: Fix the console syscall on big endian hosts Date: Fri, 8 Sep 2023 16:03:29 +1000 Message-ID: <20230908060431.1903919-4-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::62d; envelope-from=alistair23@gmail.com; helo=mail-pl1-x62d.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: 1694153186301100001 Content-Type: text/plain; charset="utf-8" From: Thomas Huth Values that have been read via cpu_physical_memory_read() from the guest's memory have to be swapped in case the host endianess differs from the guest. Fixes: a6e13e31d5 ("riscv_htif: Support console output via proxy syscall") Signed-off-by: Thomas Huth Reviewed-by: Alistair Francis Reviewed-by: Bin Meng Reviewed-by: Daniel Henrique Barboza Message-Id: <20230721094720.902454-3-thuth@redhat.com> Signed-off-by: Alistair Francis --- hw/char/riscv_htif.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/char/riscv_htif.c b/hw/char/riscv_htif.c index f96df40124..40de6b8b77 100644 --- a/hw/char/riscv_htif.c +++ b/hw/char/riscv_htif.c @@ -30,6 +30,7 @@ #include "qemu/timer.h" #include "qemu/error-report.h" #include "exec/address-spaces.h" +#include "exec/tswap.h" #include "sysemu/dma.h" =20 #define RISCV_DEBUG_HTIF 0 @@ -209,11 +210,11 @@ static void htif_handle_tohost_write(HTIFState *s, ui= nt64_t val_written) } else { uint64_t syscall[8]; cpu_physical_memory_read(payload, syscall, sizeof(syscall)= ); - if (syscall[0] =3D=3D PK_SYS_WRITE && - syscall[1] =3D=3D HTIF_DEV_CONSOLE && - syscall[3] =3D=3D HTIF_CONSOLE_CMD_PUTC) { + if (tswap64(syscall[0]) =3D=3D PK_SYS_WRITE && + tswap64(syscall[1]) =3D=3D HTIF_DEV_CONSOLE && + tswap64(syscall[3]) =3D=3D HTIF_CONSOLE_CMD_PUTC) { uint8_t ch; - cpu_physical_memory_read(syscall[2], &ch, 1); + cpu_physical_memory_read(tswap64(syscall[2]), &ch, 1); qemu_chr_fe_write(&s->chr, &ch, 1); resp =3D 0x100 | (uint8_t)payload; } else { --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153164; cv=none; d=zohomail.com; s=zohoarc; b=K7imkv/81pSihf9iOR5DLl6txAq0fP8p67kbbzF/zFCb7Hm8Axx6lpWccINbuk4JRVjzvFRj56AIBqk4/B7s0cXW4Ulb64npFTjMTS8bhLJsZHuST+q5FN+dkP8AmngcUgKIzK1DEmj8YFsthT+4Mk+nLY4WsMo+qsPYJ+Zg4/M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153164; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hxgyHj3pWoEqxLeuIclC5zzk9fMaICBkgpM0QGf+99I=; b=mRjFSbSnSyISl9wg9Z0t6vc+bbxGq5pUiGkkJ+7ONYxikwSgD3MKaXkjG61g9eecE74Mw1OLa5ClVE/vzXXF/VH9mbkOAyPtaWDChd5ITmkrJ4E8gsJfb+IZ401rKLGCV7O9ZxqSpxRH405IxCbC1H3m7AR7rab4a/v+m9Ph1YU= 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 169415316484635.08073759521949; Thu, 7 Sep 2023 23:06:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUcP-00005d-Mm; Fri, 08 Sep 2023 02:05:27 -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 1qeUcI-00004z-0F for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:05:19 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUcD-0005EF-Nf for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:05:16 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1c0ecb9a075so13474005ad.2 for ; Thu, 07 Sep 2023 23:05:12 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.05.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:05:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153110; x=1694757910; 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=hxgyHj3pWoEqxLeuIclC5zzk9fMaICBkgpM0QGf+99I=; b=TeuTgmj7FT7drz+/YoYeRI2+/rFm/+WZ3vCjawBnP58r0SCGTgybYEAxjQo4sVoRyM j4r8o4CkCGXOc/rlkDNOHI3KJA+F0GShqF3tWdmynPt1oEBG9WlM74X5P+oqemxqp5jw 3kIX2WoR2Wei/0sNXgj+Ybk2tvEyXNCC+/iXFjQ2CxI5CEFelj6xH4w3e9eMZXACyX5i ugj2BV8QI0z8Y1GpJitzMDaZCyaTUjrHyGoaMYooiKZDk//5kYeMxzPpvEPId54rLl05 VylfRTRYBFsMQo18u73FlBbJTwyDNRTdFq8+oaShksNU1+WV5SrvBazszo0zmcqjlc0Z aIXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153110; x=1694757910; 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=hxgyHj3pWoEqxLeuIclC5zzk9fMaICBkgpM0QGf+99I=; b=riqrDc5klfDj2fOaDmIsmeJU+cYwX5WFeThlCEu98p90ZgFUCqU4CxBglTvYsgYEvU PPI8p4cD3kOWvwnVsGA3to17SZwZd+TpWy//ofCPbfaAJ1JukDXVMsa2wcCAv17W2xuJ zPmbsS2YjWGBJdZ3/bpVyHr9X2DtoWAA5bNgVd8Ls0aBve+5CyiBv2QbvEIUnoIrNAsI lM4YPmYowxzpYw4pNF1xde37mijH5Q1jpJS9iYnsaKC6eJdnXKe9FHmbvNkwQAgh6j+O 3IVtvv8IE0NBRqCBFjGOouKyvQ8mpTbnhQmuSp+elOS0F63Nloz4yCoqyIUtFWAFzsMW aUfQ== X-Gm-Message-State: AOJu0YxQZNuenq0AxqOeaMyZ/aMgnqE5QpV+CfuTzq9xCE3KHmeB3khw 6YgX+pL6fMvMiTUSP7T8ORXut6USTzxnZuxo X-Google-Smtp-Source: AGHT+IGYMqqJLvdxGEVg7zlfeDJON80SxFphE/ncT0KlVk/sI5oAaau+PyaVZ307i9a5pFNvsau74Q== X-Received: by 2002:a17:903:1208:b0:1b7:e86f:7631 with SMTP id l8-20020a170903120800b001b7e86f7631mr2146476plh.19.1694153110290; Thu, 07 Sep 2023 23:05:10 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Weiwei Li , Alistair Francis Subject: [PULL 04/65] target/riscv/cpu.c: add zmmul isa string Date: Fri, 8 Sep 2023 16:03:30 +1000 Message-ID: <20230908060431.1903919-5-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::62e; envelope-from=alistair23@gmail.com; helo=mail-pl1-x62e.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: 1694153166270100001 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza zmmul was promoted from experimental to ratified in commit 6d00ffad4e95. Add a riscv,isa string for it. Fixes: 6d00ffad4e95 ("target/riscv: move zmmul out of the experimental prop= erties") Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Alistair Francis Message-Id: <20230720132424.371132-2-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 08db3d613f..6d02e85102 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -88,6 +88,7 @@ static const struct isa_ext_data isa_edata_arr[] =3D { ISA_EXT_DATA_ENTRY(zicsr, PRIV_VERSION_1_10_0, ext_icsr), ISA_EXT_DATA_ENTRY(zifencei, PRIV_VERSION_1_10_0, ext_ifencei), ISA_EXT_DATA_ENTRY(zihintpause, PRIV_VERSION_1_10_0, ext_zihintpause), + ISA_EXT_DATA_ENTRY(zmmul, PRIV_VERSION_1_12_0, ext_zmmul), ISA_EXT_DATA_ENTRY(zawrs, PRIV_VERSION_1_12_0, ext_zawrs), ISA_EXT_DATA_ENTRY(zfa, PRIV_VERSION_1_12_0, ext_zfa), ISA_EXT_DATA_ENTRY(zfbfmin, PRIV_VERSION_1_12_0, ext_zfbfmin), --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153439; cv=none; d=zohomail.com; s=zohoarc; b=ZwqgjMc6UfRtFs9FPssXDTp7HJtkRYuIJshIoNJpQN53VnewYIndLq/z33R2MWxQ4dCzNKRboVOy2DX7B8/fc+OpwUqDOpGWq2YVlWHz51UaWp1A5wr13nWXK59pF/xSBrH7bmgfa7V8vYy1U+T005wkglt80O8ireG8sTwc3Mk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153439; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=R6nXUs6b9Y10nxctaibQIThdXKgyxUl6sbEBr/ysALI=; b=SSs8RcMoxatEr+RUWq4bMm5PNrtLitmOkxdNsuPKjueX55n4MTYRW0EmHz/WAY4guhETAEdxBCHfVLfBgZQY2suOMc4iVON6QyZHcfPWtwzsLTU8aFerosesIe2sHLTPLqzhQcTfjOgLnODRhUJz3kz/07SqNQmWs/8uShRZrBc= 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 1694153439021778.6883354522914; Thu, 7 Sep 2023 23:10:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUcW-00006h-KF; Fri, 08 Sep 2023 02:05:32 -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 1qeUcI-000050-5p for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:05:19 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUcF-0005Fw-UO for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:05:17 -0400 Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-53482b44007so1286286a12.2 for ; Thu, 07 Sep 2023 23:05:15 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.05.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:05:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153114; x=1694757914; 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=R6nXUs6b9Y10nxctaibQIThdXKgyxUl6sbEBr/ysALI=; b=r3uex5DCTuwR2Vp3sdexKGvrdK6iu82fvKwj8iyzAF4w0yNMQil9a8+O6IUipjs0hU Y0UhzZ2gTKig2FZ0/RyuJbrE3E7DcuCnqaO2zAobrejRhpG2g5t5c1kYLkD/6HjoqtU2 f0Z/VKWHOZyAUZjmJeVaOi5Cjh2Puas/Yc5kisyDc/CB+tJ1qp7KRbqOVcDVBepyefuP Fyq65rKMmuBG8YDqnwo38FbqxnxAs0zCdxSNvEbXJssFGTDTjzaS54IRdsZjLlq70XoQ iv5ZyDYT5r7sTPCSJ2sNpttIcBOwVuGcUQieR1hWtBBDHmwXgpLBdvwB3O+D2hGStM8R ofCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153114; x=1694757914; 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=R6nXUs6b9Y10nxctaibQIThdXKgyxUl6sbEBr/ysALI=; b=TusVGAJn88EI6qZHQOx1I1LODRbU9SDkeQALBzWGsaunBiXg7X2Ptxotyg6tlrjdd+ l8Q0XLOw1MqjE9KaS24tI49XHUy8su61T4IJcflvP/JV8x3gP/GtHgwHgWcei+UYivSg ecE6Mapy2gurR10exCnJSM6z44kEiXzAN8fWxWWfFNLbXa9iN12gm7xoIm++7Jk04SdT OgPDB+z1WXnET3YBEkWGGLtdU2AAZ7qA6AJ+7dfeIqMW4wQjvZiCC7aF6BweZMRXe/9Z VjKlf7BAXnWMBgMjNfkAYev8W2yJzO+FHNWMEW6LWkEexY5zdBb9CiwhoAwBgIC8v8Wg qzpg== X-Gm-Message-State: AOJu0YxXq9HDRlLhYcjwGSqsF3mZ19uLDxR+OCER2GERAvy+O7eD7Thp W5iSQ/ZU+nc6uZkiPKdqVgYZKlGeP6XhML3J X-Google-Smtp-Source: AGHT+IE9OlK6HOn2AW83Oe2iSXl4ubsVaSZAj/tOlD658VjREHclUrJHb/pxci+BRybarsy2uQTYfw== X-Received: by 2002:a05:6a21:778b:b0:14d:7130:ce5f with SMTP id bd11-20020a056a21778b00b0014d7130ce5fmr1981651pzc.32.1694153113749; Thu, 07 Sep 2023 23:05:13 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Weiwei Li , Alistair Francis Subject: [PULL 05/65] target/riscv/cpu.c: add smepmp isa string Date: Fri, 8 Sep 2023 16:03:31 +1000 Message-ID: <20230908060431.1903919-6-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::52c; envelope-from=alistair23@gmail.com; helo=mail-pg1-x52c.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: 1694153439998100006 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza The cpu->cfg.epmp extension is still experimental, but it already has a 'smepmp' riscv,isa string. Add it. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Alistair Francis Message-Id: <20230720132424.371132-3-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 6d02e85102..921c19e6cd 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -130,6 +130,7 @@ static const struct isa_ext_data isa_edata_arr[] =3D { ISA_EXT_DATA_ENTRY(zhinx, PRIV_VERSION_1_12_0, ext_zhinx), ISA_EXT_DATA_ENTRY(zhinxmin, PRIV_VERSION_1_12_0, ext_zhinxmin), ISA_EXT_DATA_ENTRY(smaia, PRIV_VERSION_1_12_0, ext_smaia), + ISA_EXT_DATA_ENTRY(smepmp, PRIV_VERSION_1_12_0, epmp), ISA_EXT_DATA_ENTRY(smstateen, PRIV_VERSION_1_12_0, ext_smstateen), ISA_EXT_DATA_ENTRY(ssaia, PRIV_VERSION_1_12_0, ext_ssaia), ISA_EXT_DATA_ENTRY(sscofpmf, PRIV_VERSION_1_12_0, ext_sscofpmf), --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153689; cv=none; d=zohomail.com; s=zohoarc; b=B1xkZvEucDr7gcHTq+62Z2eXt4FRLkX6hgN+7a/phV2mBl8ENSIsaeE6C2Uzjc0S86SAiRGH21EpSHIpKiWGNK8b354i9Og1Kzok5V/D5hsZGGqdKtX23qI6h0/9GTuHav4w2nNVmYQd826QeY7uuAtmbKehin4KTrihiCGXYJY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153689; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wJk34toFNyidTQI3XnnaKroUPxNRe6WC7SlLZ/NA1WQ=; b=azCugtT7lUyGwYtSPGPK7KbvdJmmiFcDzTPpOuUEHC5Yz9fqOB10/Ckg61qDPd8AzOnYLi3TWf1Bdzh0j6N2pWh3Paq3JsNXwcr2i7zSAqySNR9+kyE76ugeYtgQDb90g4qnaNx3iE+YpvxbW2qOLeOp+9YxdELdkSx7up+hir8= 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 1694153689339811.9324718153341; Thu, 7 Sep 2023 23:14:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUcT-000068-QS; Fri, 08 Sep 2023 02:05:29 -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 1qeUcL-00005P-Uv for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:05:23 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUcJ-0005Gi-Om for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:05:21 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1c1e780aa95so12634175ad.3 for ; Thu, 07 Sep 2023 23:05:18 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.05.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:05:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153117; x=1694757917; 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=wJk34toFNyidTQI3XnnaKroUPxNRe6WC7SlLZ/NA1WQ=; b=l1wliExY8OefUX+cd/ujsaGAWLaglJRUTVZuockjGhMv4OZNXcYlWiZGDQRa+jmKlJ FAT5/ptXmpPewKjeN3W7gfRyZcMNa4SG18gXoe4D9OfcXybz1HUKrn1L1W6vBra5U8GE jwMKEQ3eI8jRjG8Ew+9kwrPctYLDCL3zKFkB7fP+Ea/OjDflInNt5CsOGHeGyKQpnSWY R3ADPoHDUU3LjpYCjI4Ce/owq1iMMga18S5w+V3vt2qbu5AeC6PC3E/8afbS+/RZiEdH tPB9yhfMHyQxpcpR29PAi1M71hR9GOCZXorkQBa6wO6y48OtN2IZZwM61hvlNtCgCHKD EU2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153117; x=1694757917; 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=wJk34toFNyidTQI3XnnaKroUPxNRe6WC7SlLZ/NA1WQ=; b=ZPvzmFooBNol3i1rSmxu5GiuV8V6MDhTgYH4J7hLT9aY/bPX1CUD4W0ZcooGLDMwzL yw2UG7ZvzVkYWpXGcy3FlkA7nhV1b71o/r8bYnaceuJOyIsrSu4PUMv6uglVzlB5Gtno Qvde/tegY8G4+IEEe/B6eT3Hett/eulESxJba37lE+AMCDDh6PewVt/ilj85ObaRc3Yw 4ptXKDeVzmGHciMVhsRZx68NgZzgcUNGBRtMdVFKMiseIca6iFYi5suxe95vVF4OI1Oo uw00PZ1nLyQlMMCVC3OtKIzhHPh+sufNF0QHEFZAURcJzhzQ55QrFsmnjIbCmRDdjMMQ 0VDQ== X-Gm-Message-State: AOJu0YxYCI2+zdQ7NXL8HrDj27OBMTHPBmnZoyDn86TZL+mQqjyVwgGx 6C8L0HLg7/dJ3ax0Z2xoa2W4p6RPckhbBkxQ X-Google-Smtp-Source: AGHT+IGbmpdEZdIuFPyazAS7/XPguCMdHTkP9BPNQvvfjrdSWRiNezCELVeYhKYwSr0djs4/8HPikg== X-Received: by 2002:a17:902:f682:b0:1c3:83e2:d0a9 with SMTP id l2-20020a170902f68200b001c383e2d0a9mr859967plg.58.1694153117125; Thu, 07 Sep 2023 23:05:17 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, LIU Zhiwei , Richard Henderson , Alistair Francis Subject: [PULL 06/65] target/riscv: Fix page_check_range use in fault-only-first Date: Fri, 8 Sep 2023 16:03:32 +1000 Message-ID: <20230908060431.1903919-7-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::632; envelope-from=alistair23@gmail.com; helo=mail-pl1-x632.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: 1694153689924100005 Content-Type: text/plain; charset="utf-8" From: LIU Zhiwei Commit bef6f008b98(accel/tcg: Return bool from page_check_range) converts integer return value to bool type. However, it wrongly converted the use of the API in riscv fault-only-first, where page_check_range < =3D 0, should be converted to !page_check_range. Signed-off-by: LIU Zhiwei Reviewed-by: Richard Henderson Message-ID: <20230729031618.821-1-zhiwei_liu@linux.alibaba.com> Signed-off-by: Alistair Francis --- target/riscv/vector_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c index bc9e151aa9..379f03df06 100644 --- a/target/riscv/vector_helper.c +++ b/target/riscv/vector_helper.c @@ -584,7 +584,7 @@ vext_ldff(void *vd, void *v0, target_ulong base, cpu_mmu_index(env, false)); if (host) { #ifdef CONFIG_USER_ONLY - if (page_check_range(addr, offset, PAGE_READ)) { + if (!page_check_range(addr, offset, PAGE_READ)) { vl =3D i; goto ProbeSuccess; } --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153176; cv=none; d=zohomail.com; s=zohoarc; b=hVH06XOzo5LCUuTv98Z7vF4RaVET+X173xE0uVKkQaRz0Wo5TeOGMid5alvDScl0grjkpf4uy6zstbt83kXlkFBIugWB0640R4elNLbDQwXfPLXxgs+NNhFdbb96a7bti7Gf/FGFTZT/F/EFziMV9KSB4A+h+k+ekHxTY81NuNY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153176; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Uzpy+y6xrg4iHp+mbMOAUvxFawE2a4d7du1HjRHTWNg=; b=d0PCeN08euf3ayZyJKtjXCe9Bl4XNClVKvVq816PgfYVz0lfGKUwO/B0CddqL7wpa2j59jaxE79k7/7LNRnhs7k1vk1qylYWpZZMFmyXwnKK6gwdUdaO0GOVnb8F4YmXFvrwv+WwCoMEGQVT6j9MWgTIchlLyq6EaDSAEtZJ7fc= 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 1694153176065933.5447964971006; Thu, 7 Sep 2023 23:06:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUcU-00006U-WA; Fri, 08 Sep 2023 02:05:31 -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 1qeUcP-00005i-M0 for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:05:27 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUcN-0005Hm-8D for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:05:25 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1bf7423ef3eso13572655ad.3 for ; Thu, 07 Sep 2023 23:05:22 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.05.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:05:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153121; x=1694757921; 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=Uzpy+y6xrg4iHp+mbMOAUvxFawE2a4d7du1HjRHTWNg=; b=Xruglzsp9cahdsfRBb2pAi09ybD3cm4Em5r+UPRaE/fd/bZTFA8TUt1SK2InjyhZGD A1AJLMW/RusUp/FGyYkM+R1UOiA+0l+lxonbcwSDc8nEA8Rmv/9kZXHRefkzsiRrQuTv kXKztVR9+t2lnltZeGF6z25V4Bj3f65MZ3pS89NSTmtHoVUS8aduQeY58w2R8QhxZDsx iH0d5EBoiS6J0Y5dMbidPB22XR/H4LA4Z3IiKjx/IB3Vg77DGQJ7gDwWm5kbUSosP4d2 GrxbTN5CUq1tdPE/O3M4gnqBMMS/WKom+d0LZS+WteNEMUyv8ZsIBisA7yQ35l3TJYt3 DI2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153121; x=1694757921; 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=Uzpy+y6xrg4iHp+mbMOAUvxFawE2a4d7du1HjRHTWNg=; b=GTWADRv0Ubha4l+hWD9tn6++7Kqjs38dKC56SfWL7T3yp5GQ+fm9orllIQkVoiHydn Kmq7r/rSEM+016fUu1qA/akaoTGXWThxT5/gLA7CyXK9/Acg7cgZJX3iibI/IuIaheYn rjIZfOtF7WQgN94+UMK5tAHU0uPHYbTTCrzY7EcW7h3GsPuHyCeMPsI3H8fxXd0FJxiE 1udHGx8TYSdbluJ9sODq1nJ8xufea5r6gjVUiHpf8ltTPwcI2Foc1JVMYZEFxTTDCXd1 +XvvSviIYG12jTH+Cdqxvi+lddPIfNyM35qjwvtL9tH4sUazjnPRhrOO/NYti0J1PeFu BRig== X-Gm-Message-State: AOJu0YxHOXAnUHcUYH4aaBKQYTL6uYlOoMz5vW5MmmPt7hraxgdOTFbJ rLqKkm6UZoIUx8t4Pf/gHzxlI8061dnxnJ76 X-Google-Smtp-Source: AGHT+IF8IgjvONVUa08Zl2PBg63WLOypm6LU7zvoQvwITkD3BCGo4ISnjg0kEk6vP2a1oclz5PNBzg== X-Received: by 2002:a17:902:d489:b0:1c0:aa07:1792 with SMTP id c9-20020a170902d48900b001c0aa071792mr1950933plg.36.1694153121561; Thu, 07 Sep 2023 23:05:21 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Ard Biesheuvel , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Zewen Ye , Weiwei Li , Junqiang Wang , Alistair Francis Subject: [PULL 07/65] target/riscv: Use existing lookup tables for MixColumns Date: Fri, 8 Sep 2023 16:03:33 +1000 Message-ID: <20230908060431.1903919-8-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::62c; envelope-from=alistair23@gmail.com; helo=mail-pl1-x62c.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: 1694153179122100005 From: Ard Biesheuvel The AES MixColumns and InvMixColumns operations are relatively expensive 4x4 matrix multiplications in GF(2^8), which is why C implementations usually rely on precomputed lookup tables rather than performing the calculations on demand. Given that we already carry those tables in QEMU, we can just grab the right value in the implementation of the RISC-V AES32 instructions. Note that the tables in question are permuted according to the respective Sbox, so we can omit the Sbox lookup as well in this case. Cc: Richard Henderson Cc: Philippe Mathieu-Daud=C3=A9 Cc: Zewen Ye Cc: Weiwei Li Cc: Junqiang Wang Signed-off-by: Ard Biesheuvel Reviewed-by: Richard Henderson Message-ID: <20230731084043.1791984-1-ardb@kernel.org> Signed-off-by: Alistair Francis --- include/crypto/aes.h | 7 +++++++ crypto/aes.c | 4 ++-- target/riscv/crypto_helper.c | 34 ++++------------------------------ 3 files changed, 13 insertions(+), 32 deletions(-) diff --git a/include/crypto/aes.h b/include/crypto/aes.h index 709d4d226b..381f24c902 100644 --- a/include/crypto/aes.h +++ b/include/crypto/aes.h @@ -30,4 +30,11 @@ void AES_decrypt(const unsigned char *in, unsigned char = *out, extern const uint8_t AES_sbox[256]; extern const uint8_t AES_isbox[256]; =20 +/* +AES_Te0[x] =3D S [x].[02, 01, 01, 03]; +AES_Td0[x] =3D Si[x].[0e, 09, 0d, 0b]; +*/ + +extern const uint32_t AES_Te0[256], AES_Td0[256]; + #endif diff --git a/crypto/aes.c b/crypto/aes.c index 836d7d5c0b..df4362ac60 100644 --- a/crypto/aes.c +++ b/crypto/aes.c @@ -272,7 +272,7 @@ AES_Td3[x] =3D Si[x].[09, 0d, 0b, 0e]; AES_Td4[x] =3D Si[x].[01, 01, 01, 01]; */ =20 -static const uint32_t AES_Te0[256] =3D { +const uint32_t AES_Te0[256] =3D { 0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU, 0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U, 0x60303050U, 0x02010103U, 0xce6767a9U, 0x562b2b7dU, @@ -607,7 +607,7 @@ static const uint32_t AES_Te4[256] =3D { 0xb0b0b0b0U, 0x54545454U, 0xbbbbbbbbU, 0x16161616U, }; =20 -static const uint32_t AES_Td0[256] =3D { +const uint32_t AES_Td0[256] =3D { 0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U, 0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U, 0x2030fa55U, 0xad766df6U, 0x88cc7691U, 0xf5024c25U, diff --git a/target/riscv/crypto_helper.c b/target/riscv/crypto_helper.c index 99d85a6188..4d65945429 100644 --- a/target/riscv/crypto_helper.c +++ b/target/riscv/crypto_helper.c @@ -25,29 +25,6 @@ #include "crypto/aes-round.h" #include "crypto/sm4.h" =20 -#define AES_XTIME(a) \ - ((a << 1) ^ ((a & 0x80) ? 0x1b : 0)) - -#define AES_GFMUL(a, b) (( \ - (((b) & 0x1) ? (a) : 0) ^ \ - (((b) & 0x2) ? AES_XTIME(a) : 0) ^ \ - (((b) & 0x4) ? AES_XTIME(AES_XTIME(a)) : 0) ^ \ - (((b) & 0x8) ? AES_XTIME(AES_XTIME(AES_XTIME(a))) : 0)) & 0xFF) - -static inline uint32_t aes_mixcolumn_byte(uint8_t x, bool fwd) -{ - uint32_t u; - - if (fwd) { - u =3D (AES_GFMUL(x, 3) << 24) | (x << 16) | (x << 8) | - (AES_GFMUL(x, 2) << 0); - } else { - u =3D (AES_GFMUL(x, 0xb) << 24) | (AES_GFMUL(x, 0xd) << 16) | - (AES_GFMUL(x, 0x9) << 8) | (AES_GFMUL(x, 0xe) << 0); - } - return u; -} - #define sext32_xlen(x) (target_ulong)(int32_t)(x) =20 static inline target_ulong aes32_operation(target_ulong shamt, @@ -55,23 +32,20 @@ static inline target_ulong aes32_operation(target_ulong= shamt, bool enc, bool mix) { uint8_t si =3D rs2 >> shamt; - uint8_t so; uint32_t mixed; target_ulong res; =20 if (enc) { - so =3D AES_sbox[si]; if (mix) { - mixed =3D aes_mixcolumn_byte(so, true); + mixed =3D be32_to_cpu(AES_Te0[si]); } else { - mixed =3D so; + mixed =3D AES_sbox[si]; } } else { - so =3D AES_isbox[si]; if (mix) { - mixed =3D aes_mixcolumn_byte(so, false); + mixed =3D be32_to_cpu(AES_Td0[si]); } else { - mixed =3D so; + mixed =3D AES_isbox[si]; } } mixed =3D rol32(mixed, shamt); --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153487; cv=none; d=zohomail.com; s=zohoarc; b=nIJwjVyR2CS2mszGoEEA6zMzmVl8NLpdN95zKvG9W5IpxgaS08l7iamOw+1OXxWMDem6WYunE1pzjKhs3t00RqV0AvmKBc4SRht3DzdNItNFi81PrAnHj7M9KYungSBKV12VjC+Lc5BOIyR5DPWJXTgKSUkmpcFaYOiBxw7zGpY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153487; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sSeyTQyuBwnxsxZ+/qUq8xyLuzir65M8yR4fVevxw4Y=; b=nRoysf7K5IdZ/X147UlQ7sno/bjaZI4cCL6oM9dLj28LXWOKMWS4RSkrZ1Vj5c5m1PLKdbdJ1pbYS2qgXUYAhlMHeE1D9h8NSuZlDCFtc0PakkBBOMQLEOp274/cUPOfEAhZfa1mhe3Sz0vVcfIiNd9d3X8JDxE/k/b8mnOUjq4= 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 1694153487689951.2319590876401; Thu, 7 Sep 2023 23:11:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUcX-00007G-Px; Fri, 08 Sep 2023 02:05:33 -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 1qeUcW-00006g-Cu for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:05:32 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUcR-0005Ir-Fb for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:05:32 -0400 Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-273ca7ab3f5so1127575a91.2 for ; Thu, 07 Sep 2023 23:05:27 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.05.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:05:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153125; x=1694757925; 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=sSeyTQyuBwnxsxZ+/qUq8xyLuzir65M8yR4fVevxw4Y=; b=gJOp3ZEHfnlPxdImzWOcpt1Eh9ZesDKNnWB+P+rWB8Y2RU16XYkVVPHAzAhcdFP6rA QgJE4L0VNx9JFbiLyrHFocPCe8S5jgfH0oXGtIlaT0RyAUhPmVGp/lSPEwJy/XeIa8Fw 1ejRAVsJBhONLzrkrLSHox2EW4lGxvhWko68BcZ1fgVxlLILQVHtAWNJfjDm+Hsq7WB2 9JCUWrdnibu69r9qYpH7U/rGqqR8Xk94OEmWPPprUJBQsQd1GvQYFy0434+AqeOgwyI5 8ZKJcaSR2/JIFjefMjl3PSqv/74qVAua41OxeYkXAFw6nhWpXcQUwLjyFdIOA7oipfMa BUgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153125; x=1694757925; 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=sSeyTQyuBwnxsxZ+/qUq8xyLuzir65M8yR4fVevxw4Y=; b=Knnm4VyexxzB8lPTbGy7Ns5s5FjLBGTlZuK4rjnQOTI0dHwqJ3War5IY3GyF/W52Lp NJjrpHfV7HKRT+MmC+dHAcxMb5gtN+mjn5P64S7eIES1hMb7jZ5Oy/ffGpRsMbdfvfF9 o1GGGzIv5+03JAdu3uXhewiRi2xPOzeymTBFJnJP9F1OrMEMTptbn6oB2BqiN3/196AI A4HknEQDJvy6WbZEtNH37RRP1kHAzxysX5QLkKtRzScJOlY60aH8RDMel0w13U/irMMz sPhwUPWjpfnFoCE10v4Ug8fwjFMM52zFtFjGUVLm68DiREB98pV+AAobZ+5wzWgxI7qF bDZQ== X-Gm-Message-State: AOJu0Yy4bPFK3tKNB4SuzCi7SP+HiYcBpp13zbzNlD+o2E2yLplPKPyh t7cUHyGSi7a/97KWVjTwL/llu4y6XXD/7w2S X-Google-Smtp-Source: AGHT+IHGSrN+g6Vg5N71z2hEcu+yHasS9BVWyXULEX6UVgKZuM0M4xe8e8W1Rq4gpYk1LrQ4UTJcFA== X-Received: by 2002:a17:90a:8815:b0:26d:287f:a545 with SMTP id s21-20020a17090a881500b0026d287fa545mr1617339pjn.29.1694153125360; Thu, 07 Sep 2023 23:05:25 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Kiran Ostrolenk , Weiwei Li , Max Chou , Alistair Francis Subject: [PULL 08/65] target/riscv: Refactor some of the generic vector functionality Date: Fri, 8 Sep 2023 16:03:34 +1000 Message-ID: <20230908060431.1903919-9-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::102c; envelope-from=alistair23@gmail.com; helo=mail-pj1-x102c.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: 1694153488047100019 Content-Type: text/plain; charset="utf-8" From: Kiran Ostrolenk Take some functions/macros out of `vector_helper` and put them in a new module called `vector_internals`. This ensures they can be used by both vector and vector-crypto helpers (latter implemented in proceeding commits). Signed-off-by: Kiran Ostrolenk Reviewed-by: Weiwei Li Signed-off-by: Max Chou Acked-by: Alistair Francis Message-ID: <20230711165917.2629866-2-max.chou@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/vector_internals.h | 182 +++++++++++++++++++++++++++++ target/riscv/vector_helper.c | 201 +------------------------------- target/riscv/vector_internals.c | 81 +++++++++++++ target/riscv/meson.build | 1 + 4 files changed, 265 insertions(+), 200 deletions(-) create mode 100644 target/riscv/vector_internals.h create mode 100644 target/riscv/vector_internals.c diff --git a/target/riscv/vector_internals.h b/target/riscv/vector_internal= s.h new file mode 100644 index 0000000000..749d138beb --- /dev/null +++ b/target/riscv/vector_internals.h @@ -0,0 +1,182 @@ +/* + * RISC-V Vector Extension Internals + * + * Copyright (c) 2020 T-Head Semiconductor Co., Ltd. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2 or later, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License f= or + * more details. + * + * You should have received a copy of the GNU General Public License along= with + * this program. If not, see . + */ + +#ifndef TARGET_RISCV_VECTOR_INTERNALS_H +#define TARGET_RISCV_VECTOR_INTERNALS_H + +#include "qemu/osdep.h" +#include "qemu/bitops.h" +#include "cpu.h" +#include "tcg/tcg-gvec-desc.h" +#include "internals.h" + +static inline uint32_t vext_nf(uint32_t desc) +{ + return FIELD_EX32(simd_data(desc), VDATA, NF); +} + +/* + * Note that vector data is stored in host-endian 64-bit chunks, + * so addressing units smaller than that needs a host-endian fixup. + */ +#if HOST_BIG_ENDIAN +#define H1(x) ((x) ^ 7) +#define H1_2(x) ((x) ^ 6) +#define H1_4(x) ((x) ^ 4) +#define H2(x) ((x) ^ 3) +#define H4(x) ((x) ^ 1) +#define H8(x) ((x)) +#else +#define H1(x) (x) +#define H1_2(x) (x) +#define H1_4(x) (x) +#define H2(x) (x) +#define H4(x) (x) +#define H8(x) (x) +#endif + +/* + * Encode LMUL to lmul as following: + * LMUL vlmul lmul + * 1 000 0 + * 2 001 1 + * 4 010 2 + * 8 011 3 + * - 100 - + * 1/8 101 -3 + * 1/4 110 -2 + * 1/2 111 -1 + */ +static inline int32_t vext_lmul(uint32_t desc) +{ + return sextract32(FIELD_EX32(simd_data(desc), VDATA, LMUL), 0, 3); +} + +static inline uint32_t vext_vm(uint32_t desc) +{ + return FIELD_EX32(simd_data(desc), VDATA, VM); +} + +static inline uint32_t vext_vma(uint32_t desc) +{ + return FIELD_EX32(simd_data(desc), VDATA, VMA); +} + +static inline uint32_t vext_vta(uint32_t desc) +{ + return FIELD_EX32(simd_data(desc), VDATA, VTA); +} + +static inline uint32_t vext_vta_all_1s(uint32_t desc) +{ + return FIELD_EX32(simd_data(desc), VDATA, VTA_ALL_1S); +} + +/* + * Earlier designs (pre-0.9) had a varying number of bits + * per mask value (MLEN). In the 0.9 design, MLEN=3D1. + * (Section 4.5) + */ +static inline int vext_elem_mask(void *v0, int index) +{ + int idx =3D index / 64; + int pos =3D index % 64; + return (((uint64_t *)v0)[idx] >> pos) & 1; +} + +/* + * Get number of total elements, including prestart, body and tail element= s. + * Note that when LMUL < 1, the tail includes the elements past VLMAX that + * are held in the same vector register. + */ +static inline uint32_t vext_get_total_elems(CPURISCVState *env, uint32_t d= esc, + uint32_t esz) +{ + uint32_t vlenb =3D simd_maxsz(desc); + uint32_t sew =3D 1 << FIELD_EX64(env->vtype, VTYPE, VSEW); + int8_t emul =3D ctzl(esz) - ctzl(sew) + vext_lmul(desc) < 0 ? 0 : + ctzl(esz) - ctzl(sew) + vext_lmul(desc); + return (vlenb << emul) / esz; +} + +/* set agnostic elements to 1s */ +void vext_set_elems_1s(void *base, uint32_t is_agnostic, uint32_t cnt, + uint32_t tot); + +/* expand macro args before macro */ +#define RVVCALL(macro, ...) macro(__VA_ARGS__) + +/* (TD, T1, T2, TX1, TX2) */ +#define OP_UUU_B uint8_t, uint8_t, uint8_t, uint8_t, uint8_t +#define OP_UUU_H uint16_t, uint16_t, uint16_t, uint16_t, uint16_t +#define OP_UUU_W uint32_t, uint32_t, uint32_t, uint32_t, uint32_t +#define OP_UUU_D uint64_t, uint64_t, uint64_t, uint64_t, uint64_t + +/* operation of two vector elements */ +typedef void opivv2_fn(void *vd, void *vs1, void *vs2, int i); + +#define OPIVV2(NAME, TD, T1, T2, TX1, TX2, HD, HS1, HS2, OP) \ +static void do_##NAME(void *vd, void *vs1, void *vs2, int i) \ +{ \ + TX1 s1 =3D *((T1 *)vs1 + HS1(i)); \ + TX2 s2 =3D *((T2 *)vs2 + HS2(i)); \ + *((TD *)vd + HD(i)) =3D OP(s2, s1); \ +} + +void do_vext_vv(void *vd, void *v0, void *vs1, void *vs2, + CPURISCVState *env, uint32_t desc, + opivv2_fn *fn, uint32_t esz); + +/* generate the helpers for OPIVV */ +#define GEN_VEXT_VV(NAME, ESZ) \ +void HELPER(NAME)(void *vd, void *v0, void *vs1, \ + void *vs2, CPURISCVState *env, \ + uint32_t desc) \ +{ \ + do_vext_vv(vd, v0, vs1, vs2, env, desc, \ + do_##NAME, ESZ); \ +} + +typedef void opivx2_fn(void *vd, target_long s1, void *vs2, int i); + +/* + * (T1)s1 gives the real operator type. + * (TX1)(T1)s1 expands the operator type of widen or narrow operations. + */ +#define OPIVX2(NAME, TD, T1, T2, TX1, TX2, HD, HS2, OP) \ +static void do_##NAME(void *vd, target_long s1, void *vs2, int i) \ +{ \ + TX2 s2 =3D *((T2 *)vs2 + HS2(i)); \ + *((TD *)vd + HD(i)) =3D OP(s2, (TX1)(T1)s1); \ +} + +void do_vext_vx(void *vd, void *v0, target_long s1, void *vs2, + CPURISCVState *env, uint32_t desc, + opivx2_fn fn, uint32_t esz); + +/* generate the helpers for OPIVX */ +#define GEN_VEXT_VX(NAME, ESZ) \ +void HELPER(NAME)(void *vd, void *v0, target_ulong s1, \ + void *vs2, CPURISCVState *env, \ + uint32_t desc) \ +{ \ + do_vext_vx(vd, v0, s1, vs2, env, desc, \ + do_##NAME, ESZ); \ +} + +#endif /* TARGET_RISCV_VECTOR_INTERNALS_H */ diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c index 379f03df06..1f29236a63 100644 --- a/target/riscv/vector_helper.c +++ b/target/riscv/vector_helper.c @@ -27,6 +27,7 @@ #include "fpu/softfloat.h" #include "tcg/tcg-gvec-desc.h" #include "internals.h" +#include "vector_internals.h" #include =20 target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1, @@ -73,68 +74,6 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_u= long s1, return vl; } =20 -/* - * Note that vector data is stored in host-endian 64-bit chunks, - * so addressing units smaller than that needs a host-endian fixup. - */ -#if HOST_BIG_ENDIAN -#define H1(x) ((x) ^ 7) -#define H1_2(x) ((x) ^ 6) -#define H1_4(x) ((x) ^ 4) -#define H2(x) ((x) ^ 3) -#define H4(x) ((x) ^ 1) -#define H8(x) ((x)) -#else -#define H1(x) (x) -#define H1_2(x) (x) -#define H1_4(x) (x) -#define H2(x) (x) -#define H4(x) (x) -#define H8(x) (x) -#endif - -static inline uint32_t vext_nf(uint32_t desc) -{ - return FIELD_EX32(simd_data(desc), VDATA, NF); -} - -static inline uint32_t vext_vm(uint32_t desc) -{ - return FIELD_EX32(simd_data(desc), VDATA, VM); -} - -/* - * Encode LMUL to lmul as following: - * LMUL vlmul lmul - * 1 000 0 - * 2 001 1 - * 4 010 2 - * 8 011 3 - * - 100 - - * 1/8 101 -3 - * 1/4 110 -2 - * 1/2 111 -1 - */ -static inline int32_t vext_lmul(uint32_t desc) -{ - return sextract32(FIELD_EX32(simd_data(desc), VDATA, LMUL), 0, 3); -} - -static inline uint32_t vext_vta(uint32_t desc) -{ - return FIELD_EX32(simd_data(desc), VDATA, VTA); -} - -static inline uint32_t vext_vma(uint32_t desc) -{ - return FIELD_EX32(simd_data(desc), VDATA, VMA); -} - -static inline uint32_t vext_vta_all_1s(uint32_t desc) -{ - return FIELD_EX32(simd_data(desc), VDATA, VTA_ALL_1S); -} - /* * Get the maximum number of elements can be operated. * @@ -153,21 +92,6 @@ static inline uint32_t vext_max_elems(uint32_t desc, ui= nt32_t log2_esz) return scale < 0 ? vlenb >> -scale : vlenb << scale; } =20 -/* - * Get number of total elements, including prestart, body and tail element= s. - * Note that when LMUL < 1, the tail includes the elements past VLMAX that - * are held in the same vector register. - */ -static inline uint32_t vext_get_total_elems(CPURISCVState *env, uint32_t d= esc, - uint32_t esz) -{ - uint32_t vlenb =3D simd_maxsz(desc); - uint32_t sew =3D 1 << FIELD_EX64(env->vtype, VTYPE, VSEW); - int8_t emul =3D ctzl(esz) - ctzl(sew) + vext_lmul(desc) < 0 ? 0 : - ctzl(esz) - ctzl(sew) + vext_lmul(desc); - return (vlenb << emul) / esz; -} - static inline target_ulong adjust_addr(CPURISCVState *env, target_ulong ad= dr) { return (addr & ~env->cur_pmmask) | env->cur_pmbase; @@ -200,20 +124,6 @@ static void probe_pages(CPURISCVState *env, target_ulo= ng addr, } } =20 -/* set agnostic elements to 1s */ -static void vext_set_elems_1s(void *base, uint32_t is_agnostic, uint32_t c= nt, - uint32_t tot) -{ - if (is_agnostic =3D=3D 0) { - /* policy undisturbed */ - return; - } - if (tot - cnt =3D=3D 0) { - return; - } - memset(base + cnt, -1, tot - cnt); -} - static inline void vext_set_elem_mask(void *v0, int index, uint8_t value) { @@ -223,18 +133,6 @@ static inline void vext_set_elem_mask(void *v0, int in= dex, ((uint64_t *)v0)[idx] =3D deposit64(old, pos, 1, value); } =20 -/* - * Earlier designs (pre-0.9) had a varying number of bits - * per mask value (MLEN). In the 0.9 design, MLEN=3D1. - * (Section 4.5) - */ -static inline int vext_elem_mask(void *v0, int index) -{ - int idx =3D index / 64; - int pos =3D index % 64; - return (((uint64_t *)v0)[idx] >> pos) & 1; -} - /* elements operations for load and store */ typedef void vext_ldst_elem_fn(CPURISCVState *env, abi_ptr addr, uint32_t idx, void *vd, uintptr_t retaddr); @@ -729,18 +627,11 @@ GEN_VEXT_ST_WHOLE(vs8r_v, int8_t, ste_b) * Vector Integer Arithmetic Instructions */ =20 -/* expand macro args before macro */ -#define RVVCALL(macro, ...) macro(__VA_ARGS__) - /* (TD, T1, T2, TX1, TX2) */ #define OP_SSS_B int8_t, int8_t, int8_t, int8_t, int8_t #define OP_SSS_H int16_t, int16_t, int16_t, int16_t, int16_t #define OP_SSS_W int32_t, int32_t, int32_t, int32_t, int32_t #define OP_SSS_D int64_t, int64_t, int64_t, int64_t, int64_t -#define OP_UUU_B uint8_t, uint8_t, uint8_t, uint8_t, uint8_t -#define OP_UUU_H uint16_t, uint16_t, uint16_t, uint16_t, uint16_t -#define OP_UUU_W uint32_t, uint32_t, uint32_t, uint32_t, uint32_t -#define OP_UUU_D uint64_t, uint64_t, uint64_t, uint64_t, uint64_t #define OP_SUS_B int8_t, uint8_t, int8_t, uint8_t, int8_t #define OP_SUS_H int16_t, uint16_t, int16_t, uint16_t, int16_t #define OP_SUS_W int32_t, uint32_t, int32_t, uint32_t, int32_t @@ -764,16 +655,6 @@ GEN_VEXT_ST_WHOLE(vs8r_v, int8_t, ste_b) #define NOP_UUU_H uint16_t, uint16_t, uint32_t, uint16_t, uint32_t #define NOP_UUU_W uint32_t, uint32_t, uint64_t, uint32_t, uint64_t =20 -/* operation of two vector elements */ -typedef void opivv2_fn(void *vd, void *vs1, void *vs2, int i); - -#define OPIVV2(NAME, TD, T1, T2, TX1, TX2, HD, HS1, HS2, OP) \ -static void do_##NAME(void *vd, void *vs1, void *vs2, int i) \ -{ \ - TX1 s1 =3D *((T1 *)vs1 + HS1(i)); \ - TX2 s2 =3D *((T2 *)vs2 + HS2(i)); \ - *((TD *)vd + HD(i)) =3D OP(s2, s1); \ -} #define DO_SUB(N, M) (N - M) #define DO_RSUB(N, M) (M - N) =20 @@ -786,40 +667,6 @@ RVVCALL(OPIVV2, vsub_vv_h, OP_SSS_H, H2, H2, H2, DO_SU= B) RVVCALL(OPIVV2, vsub_vv_w, OP_SSS_W, H4, H4, H4, DO_SUB) RVVCALL(OPIVV2, vsub_vv_d, OP_SSS_D, H8, H8, H8, DO_SUB) =20 -static void do_vext_vv(void *vd, void *v0, void *vs1, void *vs2, - CPURISCVState *env, uint32_t desc, - opivv2_fn *fn, uint32_t esz) -{ - uint32_t vm =3D vext_vm(desc); - uint32_t vl =3D env->vl; - uint32_t total_elems =3D vext_get_total_elems(env, desc, esz); - uint32_t vta =3D vext_vta(desc); - uint32_t vma =3D vext_vma(desc); - uint32_t i; - - for (i =3D env->vstart; i < vl; i++) { - if (!vm && !vext_elem_mask(v0, i)) { - /* set masked-off elements to 1s */ - vext_set_elems_1s(vd, vma, i * esz, (i + 1) * esz); - continue; - } - fn(vd, vs1, vs2, i); - } - env->vstart =3D 0; - /* set tail elements to 1s */ - vext_set_elems_1s(vd, vta, vl * esz, total_elems * esz); -} - -/* generate the helpers for OPIVV */ -#define GEN_VEXT_VV(NAME, ESZ) \ -void HELPER(NAME)(void *vd, void *v0, void *vs1, \ - void *vs2, CPURISCVState *env, \ - uint32_t desc) \ -{ \ - do_vext_vv(vd, v0, vs1, vs2, env, desc, \ - do_##NAME, ESZ); \ -} - GEN_VEXT_VV(vadd_vv_b, 1) GEN_VEXT_VV(vadd_vv_h, 2) GEN_VEXT_VV(vadd_vv_w, 4) @@ -829,18 +676,6 @@ GEN_VEXT_VV(vsub_vv_h, 2) GEN_VEXT_VV(vsub_vv_w, 4) GEN_VEXT_VV(vsub_vv_d, 8) =20 -typedef void opivx2_fn(void *vd, target_long s1, void *vs2, int i); - -/* - * (T1)s1 gives the real operator type. - * (TX1)(T1)s1 expands the operator type of widen or narrow operations. - */ -#define OPIVX2(NAME, TD, T1, T2, TX1, TX2, HD, HS2, OP) \ -static void do_##NAME(void *vd, target_long s1, void *vs2, int i) \ -{ \ - TX2 s2 =3D *((T2 *)vs2 + HS2(i)); \ - *((TD *)vd + HD(i)) =3D OP(s2, (TX1)(T1)s1); \ -} =20 RVVCALL(OPIVX2, vadd_vx_b, OP_SSS_B, H1, H1, DO_ADD) RVVCALL(OPIVX2, vadd_vx_h, OP_SSS_H, H2, H2, DO_ADD) @@ -855,40 +690,6 @@ RVVCALL(OPIVX2, vrsub_vx_h, OP_SSS_H, H2, H2, DO_RSUB) RVVCALL(OPIVX2, vrsub_vx_w, OP_SSS_W, H4, H4, DO_RSUB) RVVCALL(OPIVX2, vrsub_vx_d, OP_SSS_D, H8, H8, DO_RSUB) =20 -static void do_vext_vx(void *vd, void *v0, target_long s1, void *vs2, - CPURISCVState *env, uint32_t desc, - opivx2_fn fn, uint32_t esz) -{ - uint32_t vm =3D vext_vm(desc); - uint32_t vl =3D env->vl; - uint32_t total_elems =3D vext_get_total_elems(env, desc, esz); - uint32_t vta =3D vext_vta(desc); - uint32_t vma =3D vext_vma(desc); - uint32_t i; - - for (i =3D env->vstart; i < vl; i++) { - if (!vm && !vext_elem_mask(v0, i)) { - /* set masked-off elements to 1s */ - vext_set_elems_1s(vd, vma, i * esz, (i + 1) * esz); - continue; - } - fn(vd, s1, vs2, i); - } - env->vstart =3D 0; - /* set tail elements to 1s */ - vext_set_elems_1s(vd, vta, vl * esz, total_elems * esz); -} - -/* generate the helpers for OPIVX */ -#define GEN_VEXT_VX(NAME, ESZ) \ -void HELPER(NAME)(void *vd, void *v0, target_ulong s1, \ - void *vs2, CPURISCVState *env, \ - uint32_t desc) \ -{ \ - do_vext_vx(vd, v0, s1, vs2, env, desc, \ - do_##NAME, ESZ); \ -} - GEN_VEXT_VX(vadd_vx_b, 1) GEN_VEXT_VX(vadd_vx_h, 2) GEN_VEXT_VX(vadd_vx_w, 4) diff --git a/target/riscv/vector_internals.c b/target/riscv/vector_internal= s.c new file mode 100644 index 0000000000..9cf5c17cde --- /dev/null +++ b/target/riscv/vector_internals.c @@ -0,0 +1,81 @@ +/* + * RISC-V Vector Extension Internals + * + * Copyright (c) 2020 T-Head Semiconductor Co., Ltd. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2 or later, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License f= or + * more details. + * + * You should have received a copy of the GNU General Public License along= with + * this program. If not, see . + */ + +#include "vector_internals.h" + +/* set agnostic elements to 1s */ +void vext_set_elems_1s(void *base, uint32_t is_agnostic, uint32_t cnt, + uint32_t tot) +{ + if (is_agnostic =3D=3D 0) { + /* policy undisturbed */ + return; + } + if (tot - cnt =3D=3D 0) { + return ; + } + memset(base + cnt, -1, tot - cnt); +} + +void do_vext_vv(void *vd, void *v0, void *vs1, void *vs2, + CPURISCVState *env, uint32_t desc, + opivv2_fn *fn, uint32_t esz) +{ + uint32_t vm =3D vext_vm(desc); + uint32_t vl =3D env->vl; + uint32_t total_elems =3D vext_get_total_elems(env, desc, esz); + uint32_t vta =3D vext_vta(desc); + uint32_t vma =3D vext_vma(desc); + uint32_t i; + + for (i =3D env->vstart; i < vl; i++) { + if (!vm && !vext_elem_mask(v0, i)) { + /* set masked-off elements to 1s */ + vext_set_elems_1s(vd, vma, i * esz, (i + 1) * esz); + continue; + } + fn(vd, vs1, vs2, i); + } + env->vstart =3D 0; + /* set tail elements to 1s */ + vext_set_elems_1s(vd, vta, vl * esz, total_elems * esz); +} + +void do_vext_vx(void *vd, void *v0, target_long s1, void *vs2, + CPURISCVState *env, uint32_t desc, + opivx2_fn fn, uint32_t esz) +{ + uint32_t vm =3D vext_vm(desc); + uint32_t vl =3D env->vl; + uint32_t total_elems =3D vext_get_total_elems(env, desc, esz); + uint32_t vta =3D vext_vta(desc); + uint32_t vma =3D vext_vma(desc); + uint32_t i; + + for (i =3D env->vstart; i < vl; i++) { + if (!vm && !vext_elem_mask(v0, i)) { + /* set masked-off elements to 1s */ + vext_set_elems_1s(vd, vma, i * esz, (i + 1) * esz); + continue; + } + fn(vd, s1, vs2, i); + } + env->vstart =3D 0; + /* set tail elements to 1s */ + vext_set_elems_1s(vd, vta, vl * esz, total_elems * esz); +} diff --git a/target/riscv/meson.build b/target/riscv/meson.build index 7f56c5f88d..c3801ee5e0 100644 --- a/target/riscv/meson.build +++ b/target/riscv/meson.build @@ -16,6 +16,7 @@ riscv_ss.add(files( 'gdbstub.c', 'op_helper.c', 'vector_helper.c', + 'vector_internals.c', 'bitmanip_helper.c', 'translate.c', 'm128_helper.c', --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153194; cv=none; d=zohomail.com; s=zohoarc; b=Nqnj/Fmo+Y17w8mwZjA8x/JegFBHZ6br07yCZtri2zRoWFVW7UnFsnOXxtapO8nN0ylBcQP/Np5GcvX1EKq/ulQiQ2ytzQparOXED2JNBpPwV5WzUQbg0FgxXqYp7Dk0AbQ9VSFw5mtRSfr/AaSKiTXODealwc3c9QI7vx8vUv4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153194; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=t42yn+oYadmT6y4aQwh0PMy8AeiO4fsAPMfBk3JhGW4=; b=ZldiJ1cqlcZPb75pFh1WVUz1sTMnEx0YSk7xjQuGoylmXlcfuQgcPipoiSKDcBx7gCGcTdqzdDtLesJZw3S+et/DVmVDDlOQDgzGeS0jWEdhEj65BMDm3QNW0kp7km90AOvtSq/wzH5JGoi7cRMQ9hSRksTqVNt0t0p0OMIi+hQ= 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 1694153194857813.1232228384446; Thu, 7 Sep 2023 23:06:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUcf-00007y-Q5; Fri, 08 Sep 2023 02:05:42 -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 1qeUcY-00007l-Mk for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:05:35 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUcV-0005KC-Ab for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:05:33 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-68c0d4cc3a4so1497982b3a.1 for ; Thu, 07 Sep 2023 23:05:30 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.05.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:05:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153129; x=1694757929; 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=t42yn+oYadmT6y4aQwh0PMy8AeiO4fsAPMfBk3JhGW4=; b=pGj2w67a215TBtiEVVc7YaU5OhcjAs+4OySVHh9yCIFbxojhLGECW0E83r0pLpgiuF hKFdRCSmEy0RNKMTWzNHgT1Ih34pbkfD/rAZDw02x/TzApdmroxUDBC6n0HcscOkhG0E ffk6c54k6aFL5aOXkWiiFFBJooZOfoXZUGMmvhLkD/U9RlGqHmn43gx1iGpk5F+T0/kH CdY6JgeD4qimkjzvAZuhmbzrKQpJmA58TK4c7whMbXU3j5sZLsDT3mZLBHZ6CO+c1P4N imfQlVVankfKvH0c1KlM1ZSUYgGqgvN69qNFEpQvTgg26ky/l+J/CqS1No2n54yWvCZ3 N+zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153129; x=1694757929; 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=t42yn+oYadmT6y4aQwh0PMy8AeiO4fsAPMfBk3JhGW4=; b=MsSe6n7yr/VD014TOa4n3BOWHg/8RBFikfHhw7h1Vs4p57HHnZtyI6YhFQKUlHX0H3 3c/i36ddjWC9SE0k1dH86g0I+w21Wcwgyobs+UzI717QYYkMt4JZvHGxwFg3Tis4AT9n DM25VJA+9WuEvFsbha/CADxE8yfb/hpfuEtqSHbyPm5aJ8gkCRDObvkDQ0IAprZnMy77 OqCayqojDjJClkIrdqmJYKsJRF1Yvv3uQoTZRQ17BnPH4OJS18JNj970UZSjArupLeQ5 K9Jk4Qxo6ITjA0GadkIz9hPbKdy0cKIZs4O+tCJFyUYRv75n29izUduzZSlD1U6Q2urn KUhw== X-Gm-Message-State: AOJu0YyR8r2Viy6fXbHm1DANncSHHvGI0glbYCM7TJNd8cVRqbSRXpC+ XMCc37YXS06tFzP2DblKFdNzfvKq2BGqJwG2 X-Google-Smtp-Source: AGHT+IFqhThSsglHfu6L+lKbrGsVjT0RmFueot1PViCwJMUQ1G18eAQvXKceOdlEgUJjDB/2f7iWdw== X-Received: by 2002:a05:6300:8084:b0:140:48d4:8199 with SMTP id ap4-20020a056300808400b0014048d48199mr1799076pzc.24.1694153129321; Thu, 07 Sep 2023 23:05:29 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Kiran Ostrolenk , Richard Henderson , Alistair Francis , Weiwei Li , Max Chou Subject: [PULL 09/65] target/riscv: Refactor vector-vector translation macro Date: Fri, 8 Sep 2023 16:03:35 +1000 Message-ID: <20230908060431.1903919-10-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::42f; envelope-from=alistair23@gmail.com; helo=mail-pf1-x42f.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: 1694153196558100002 Content-Type: text/plain; charset="utf-8" From: Kiran Ostrolenk Refactor the non SEW-specific stuff out of `GEN_OPIVV_TRANS` into function `opivv_trans` (similar to `opivi_trans`). `opivv_trans` will be used in proceeding vector-crypto commits. Signed-off-by: Kiran Ostrolenk Reviewed-by: Richard Henderson Reviewed-by: Alistair Francis Reviewed-by: Weiwei Li Signed-off-by: Max Chou Message-ID: <20230711165917.2629866-3-max.chou@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/insn_trans/trans_rvv.c.inc | 62 +++++++++++++------------ 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_tr= ans/trans_rvv.c.inc index c2f7527f53..4a8e62a8be 100644 --- a/target/riscv/insn_trans/trans_rvv.c.inc +++ b/target/riscv/insn_trans/trans_rvv.c.inc @@ -1643,38 +1643,40 @@ GEN_OPIWX_WIDEN_TRANS(vwadd_wx) GEN_OPIWX_WIDEN_TRANS(vwsubu_wx) GEN_OPIWX_WIDEN_TRANS(vwsub_wx) =20 +static bool opivv_trans(uint32_t vd, uint32_t vs1, uint32_t vs2, uint32_t = vm, + gen_helper_gvec_4_ptr *fn, DisasContext *s) +{ + uint32_t data =3D 0; + TCGLabel *over =3D gen_new_label(); + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); + tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); + + data =3D FIELD_DP32(data, VDATA, VM, vm); + data =3D FIELD_DP32(data, VDATA, LMUL, s->lmul); + data =3D FIELD_DP32(data, VDATA, VTA, s->vta); + data =3D FIELD_DP32(data, VDATA, VTA_ALL_1S, s->cfg_vta_all_1s); + data =3D FIELD_DP32(data, VDATA, VMA, s->vma); + tcg_gen_gvec_4_ptr(vreg_ofs(s, vd), vreg_ofs(s, 0), vreg_ofs(s, vs1), + vreg_ofs(s, vs2), cpu_env, s->cfg_ptr->vlen / 8, + s->cfg_ptr->vlen / 8, data, fn); + mark_vs_dirty(s); + gen_set_label(over); + return true; +} + /* Vector Integer Add-with-Carry / Subtract-with-Borrow Instructions */ /* OPIVV without GVEC IR */ -#define GEN_OPIVV_TRANS(NAME, CHECK) \ -static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ -{ \ - if (CHECK(s, a)) { \ - uint32_t data =3D 0; \ - static gen_helper_gvec_4_ptr * const fns[4] =3D { \ - gen_helper_##NAME##_b, gen_helper_##NAME##_h, \ - gen_helper_##NAME##_w, gen_helper_##NAME##_d, \ - }; \ - TCGLabel *over =3D gen_new_label(); \ - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ - tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \ - \ - data =3D FIELD_DP32(data, VDATA, VM, a->vm); \ - data =3D FIELD_DP32(data, VDATA, LMUL, s->lmul); \ - data =3D FIELD_DP32(data, VDATA, VTA, s->vta); \ - data =3D \ - FIELD_DP32(data, VDATA, VTA_ALL_1S, s->cfg_vta_all_1s);\ - data =3D FIELD_DP32(data, VDATA, VMA, s->vma); \ - tcg_gen_gvec_4_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), \ - vreg_ofs(s, a->rs1), \ - vreg_ofs(s, a->rs2), cpu_env, \ - s->cfg_ptr->vlen / 8, \ - s->cfg_ptr->vlen / 8, data, \ - fns[s->sew]); \ - mark_vs_dirty(s); \ - gen_set_label(over); \ - return true; \ - } \ - return false; \ +#define GEN_OPIVV_TRANS(NAME, CHECK) \ +static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ +{ \ + if (CHECK(s, a)) { \ + static gen_helper_gvec_4_ptr * const fns[4] =3D { = \ + gen_helper_##NAME##_b, gen_helper_##NAME##_h, \ + gen_helper_##NAME##_w, gen_helper_##NAME##_d, \ + }; \ + return opivv_trans(a->rd, a->rs1, a->rs2, a->vm, fns[s->sew], s);\ + } \ + return false; \ } =20 /* --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153190; cv=none; d=zohomail.com; s=zohoarc; b=HoAHdBKXjQOer0fK85AaF60B3tc4dt9Oo8t2/SkmTGOZxNsbPlCPP/JjmjipeQoMaLX015TUIPQvRigOGSzWVHYpai8fku+kiQErB+0nWTrArFJnJRlND2x+pGeNhdsdmDt5dmzHMq3HJTpQVyGP8DOf4MfWQLDny/zsif51pX0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153190; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tGOdfgfQ8KeHAJW/aE1HMl1JdKMNVXcaemj6ya20yXc=; b=LAjlgwhKS6veKtodpBM9XVLzXQNfs+v95fIrZlXpB/IMNC3+MNz8of9NQNMZu8O0RTUAguyE+TQLNV7x1dptVmkEgrw9+gjOffaLvXLcSUrviXe0zTH/Briu1dDOOAVyE/U2V1zyWJ5eJbYh1WCv7ORZE+dlPH0mNIVfl+nOGWM= 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 169415319002555.759807260732714; Thu, 7 Sep 2023 23:06:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUck-0000Eb-3W; Fri, 08 Sep 2023 02:05:46 -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 1qeUcc-00008H-Uf for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:05:41 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUca-0005NT-9L for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:05:38 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1c364fb8a4cso15562325ad.1 for ; Thu, 07 Sep 2023 23:05:34 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.05.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:05:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153133; x=1694757933; 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=tGOdfgfQ8KeHAJW/aE1HMl1JdKMNVXcaemj6ya20yXc=; b=Fikr/ts2GXYhzDWFAQpFQHA9OG23zwcyunhgLN4Q/B0YVvAJx2duKJCKe6Cce/3YOT U4qToOlaSyvQykTtuH+WLwkrn9zPlQ7mCOsa3yRbtFsBGCkKKUyuS9LPKZXNL2Khg8v3 ct8ig2lOFV5KdvR1uEYVSaZrVKhmX8T7icp2W3Lbu+0Ul4pvuN4FGpzYwxVBgqBnVGbe KHm0KOKRUyBupB+oqVL8exUpUNwhCpXpRx2UZjua485z8/I0aPkRKXVC8EFGtUbD3zJ0 ufq2DAtlsI4mNto2OPo2i+b7RrXcVtHRTs7/Q0hvFXHpunRZEqCAPuSu//IaBgm3ZrNY XunA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153133; x=1694757933; 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=tGOdfgfQ8KeHAJW/aE1HMl1JdKMNVXcaemj6ya20yXc=; b=JKIbUOi/dImWCQIbCnMmZl5/qhKlkWaBUHstNGpKsWBC8zDy58bfdWc9/xNqtEOoaX A96b3Ur8DBbUS7+W2JCyGH474nsbW8DeM6N+53kLqGH3FGPNqg+ELOIu8opVwo9EqjFe mrkKJYYv7Deqblby0kLYLvJfovCnBlxWq1uvUV/u+NUeLl5+26s1YlYZ7dBIDf6CwZPh airtBNpWp9IsmU2XE3l836SOxwGBneMu0BMXPQ+G2hUpptqolodt4J+prSMmc/dhQDqh J51Jiqe1DKme5zRE8G9dV8q3tBmIWxdu7Ad4ZLCaDboShAKsiVyLreP5GNR1tcTMJQ8y Es/Q== X-Gm-Message-State: AOJu0Yxi0UpygQgvhqIuHfDXo+wxvCk4drrQDO/zHQOXoq1P7tZf+he7 htVhcQT2bvEfW6z5mAaaTo55Vnh6jxRu0/iI X-Google-Smtp-Source: AGHT+IF8YJUNl+/jd5j1FdNqdJbt8eOJQ8/Bb4du6BXttK7xkEJ4BPqeE+HTnlAzSnF+xb9hske49Q== X-Received: by 2002:a17:902:db11:b0:1bc:61d6:5fcc with SMTP id m17-20020a170902db1100b001bc61d65fccmr1688306plx.51.1694153133353; Thu, 07 Sep 2023 23:05:33 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Nazar Kazakov , Weiwei Li , Max Chou , Alistair Francis Subject: [PULL 10/65] target/riscv: Remove redundant "cpu_vl == 0" checks Date: Fri, 8 Sep 2023 16:03:36 +1000 Message-ID: <20230908060431.1903919-11-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::62e; envelope-from=alistair23@gmail.com; helo=mail-pl1-x62e.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: 1694153191445100003 Content-Type: text/plain; charset="utf-8" From: Nazar Kazakov Remove the redundant "vl =3D=3D 0" check which is already included within t= he vstart >=3D vl check, when vl =3D=3D 0. Signed-off-by: Nazar Kazakov Reviewed-by: Weiwei Li Signed-off-by: Max Chou Acked-by: Alistair Francis Message-ID: <20230711165917.2629866-4-max.chou@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/insn_trans/trans_rvv.c.inc | 31 +------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_tr= ans/trans_rvv.c.inc index 4a8e62a8be..7e194aae34 100644 --- a/target/riscv/insn_trans/trans_rvv.c.inc +++ b/target/riscv/insn_trans/trans_rvv.c.inc @@ -617,7 +617,6 @@ static bool ldst_us_trans(uint32_t vd, uint32_t rs1, ui= nt32_t data, TCGv_i32 desc; =20 TCGLabel *over =3D gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); =20 dest =3D tcg_temp_new_ptr(); @@ -786,7 +785,6 @@ static bool ldst_stride_trans(uint32_t vd, uint32_t rs1= , uint32_t rs2, TCGv_i32 desc; =20 TCGLabel *over =3D gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); =20 dest =3D tcg_temp_new_ptr(); @@ -893,7 +891,6 @@ static bool ldst_index_trans(uint32_t vd, uint32_t rs1,= uint32_t vs2, TCGv_i32 desc; =20 TCGLabel *over =3D gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); =20 dest =3D tcg_temp_new_ptr(); @@ -1034,7 +1031,6 @@ static bool ldff_trans(uint32_t vd, uint32_t rs1, uin= t32_t data, TCGv_i32 desc; =20 TCGLabel *over =3D gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); =20 dest =3D tcg_temp_new_ptr(); @@ -1191,7 +1187,6 @@ do_opivv_gvec(DisasContext *s, arg_rmrr *a, GVecGen3F= n *gvec_fn, return false; } =20 - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); =20 if (a->vm && s->vl_eq_vlmax && !(s->vta && s->lmul < 0)) { @@ -1241,7 +1236,6 @@ static bool opivx_trans(uint32_t vd, uint32_t rs1, ui= nt32_t vs2, uint32_t vm, uint32_t data =3D 0; =20 TCGLabel *over =3D gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); =20 dest =3D tcg_temp_new_ptr(); @@ -1405,7 +1399,6 @@ static bool opivi_trans(uint32_t vd, uint32_t imm, ui= nt32_t vs2, uint32_t vm, uint32_t data =3D 0; =20 TCGLabel *over =3D gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); =20 dest =3D tcg_temp_new_ptr(); @@ -1492,7 +1485,6 @@ static bool do_opivv_widen(DisasContext *s, arg_rmrr = *a, if (checkfn(s, a)) { uint32_t data =3D 0; TCGLabel *over =3D gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); =20 data =3D FIELD_DP32(data, VDATA, VM, a->vm); @@ -1575,7 +1567,6 @@ static bool do_opiwv_widen(DisasContext *s, arg_rmrr = *a, if (opiwv_widen_check(s, a)) { uint32_t data =3D 0; TCGLabel *over =3D gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); =20 data =3D FIELD_DP32(data, VDATA, VM, a->vm); @@ -1648,7 +1639,6 @@ static bool opivv_trans(uint32_t vd, uint32_t vs1, ui= nt32_t vs2, uint32_t vm, { uint32_t data =3D 0; TCGLabel *over =3D gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); =20 data =3D FIELD_DP32(data, VDATA, VM, vm); @@ -1842,7 +1832,6 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a= ) \ gen_helper_##NAME##_w, \ }; \ TCGLabel *over =3D gen_new_label(); \ - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \ \ data =3D FIELD_DP32(data, VDATA, VM, a->vm); \ @@ -2054,7 +2043,6 @@ static bool trans_vmv_v_v(DisasContext *s, arg_vmv_v_= v *a) gen_helper_vmv_v_v_w, gen_helper_vmv_v_v_d, }; TCGLabel *over =3D gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); =20 tcg_gen_gvec_2_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, a->rs1), @@ -2078,7 +2066,6 @@ static bool trans_vmv_v_x(DisasContext *s, arg_vmv_v_= x *a) vext_check_ss(s, a->rd, 0, 1)) { TCGv s1; TCGLabel *over =3D gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); =20 s1 =3D get_gpr(s, a->rs1, EXT_SIGN); @@ -2140,7 +2127,6 @@ static bool trans_vmv_v_i(DisasContext *s, arg_vmv_v_= i *a) gen_helper_vmv_v_x_w, gen_helper_vmv_v_x_d, }; TCGLabel *over =3D gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); =20 s1 =3D tcg_constant_i64(simm); @@ -2288,7 +2274,6 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a= ) \ }; \ TCGLabel *over =3D gen_new_label(); \ gen_set_rm(s, RISCV_FRM_DYN); \ - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \ \ data =3D FIELD_DP32(data, VDATA, VM, a->vm); \ @@ -2323,7 +2308,6 @@ static bool opfvf_trans(uint32_t vd, uint32_t rs1, ui= nt32_t vs2, TCGv_i64 t1; =20 TCGLabel *over =3D gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); =20 dest =3D tcg_temp_new_ptr(); @@ -2408,7 +2392,6 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a= ) \ }; \ TCGLabel *over =3D gen_new_label(); \ gen_set_rm(s, RISCV_FRM_DYN); \ - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);\ \ data =3D FIELD_DP32(data, VDATA, VM, a->vm); \ @@ -2483,7 +2466,6 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a= ) \ }; \ TCGLabel *over =3D gen_new_label(); \ gen_set_rm(s, RISCV_FRM_DYN); \ - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \ \ data =3D FIELD_DP32(data, VDATA, VM, a->vm); \ @@ -2601,7 +2583,6 @@ static bool do_opfv(DisasContext *s, arg_rmr *a, uint32_t data =3D 0; TCGLabel *over =3D gen_new_label(); gen_set_rm_chkfrm(s, rm); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); =20 data =3D FIELD_DP32(data, VDATA, VM, a->vm); @@ -2713,7 +2694,6 @@ static bool trans_vfmv_v_f(DisasContext *s, arg_vfmv_= v_f *a) gen_helper_vmv_v_x_d, }; TCGLabel *over =3D gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); =20 t1 =3D tcg_temp_new_i64(); @@ -2792,7 +2772,6 @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a)= \ }; \ TCGLabel *over =3D gen_new_label(); \ gen_set_rm_chkfrm(s, FRM); \ - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \ \ data =3D FIELD_DP32(data, VDATA, VM, a->vm); \ @@ -2844,7 +2823,6 @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a)= \ }; \ TCGLabel *over =3D gen_new_label(); \ gen_set_rm(s, RISCV_FRM_DYN); \ - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \ \ data =3D FIELD_DP32(data, VDATA, VM, a->vm); \ @@ -2912,7 +2890,6 @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a)= \ }; \ TCGLabel *over =3D gen_new_label(); \ gen_set_rm_chkfrm(s, FRM); \ - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \ \ data =3D FIELD_DP32(data, VDATA, VM, a->vm); \ @@ -2962,7 +2939,6 @@ static bool trans_##NAME(DisasContext *s, arg_rmr *a)= \ }; \ TCGLabel *over =3D gen_new_label(); \ gen_set_rm_chkfrm(s, FRM); \ - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \ \ data =3D FIELD_DP32(data, VDATA, VM, a->vm); \ @@ -3053,7 +3029,6 @@ static bool trans_##NAME(DisasContext *s, arg_r *a) = \ uint32_t data =3D 0; \ gen_helper_gvec_4_ptr *fn =3D gen_helper_##NAME; \ TCGLabel *over =3D gen_new_label(); \ - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); \ tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); \ \ data =3D FIELD_DP32(data, VDATA, LMUL, s->lmul); \ @@ -3224,7 +3199,6 @@ static bool trans_vid_v(DisasContext *s, arg_vid_v *a) require_vm(a->vm, a->rd)) { uint32_t data =3D 0; TCGLabel *over =3D gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); =20 data =3D FIELD_DP32(data, VDATA, VM, a->vm); @@ -3411,7 +3385,6 @@ static bool trans_vmv_s_x(DisasContext *s, arg_vmv_s_= x *a) TCGv s1; TCGLabel *over =3D gen_new_label(); =20 - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); =20 t1 =3D tcg_temp_new_i64(); @@ -3468,8 +3441,7 @@ static bool trans_vfmv_s_f(DisasContext *s, arg_vfmv_= s_f *a) TCGv_i64 t1; TCGLabel *over =3D gen_new_label(); =20 - /* if vl =3D=3D 0 or vstart >=3D vl, skip vector register write ba= ck */ - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); + /* if vstart >=3D vl, skip vector register write back */ tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); =20 /* NaN-box f[rs1] */ @@ -3720,7 +3692,6 @@ static bool int_ext_op(DisasContext *s, arg_rmr *a, u= int8_t seq) uint32_t data =3D 0; gen_helper_gvec_3_ptr *fn; TCGLabel *over =3D gen_new_label(); - tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vl, 0, over); tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); =20 static gen_helper_gvec_3_ptr * const fns[6][4] =3D { --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153290; cv=none; d=zohomail.com; s=zohoarc; b=drLD2r8vBL8KIQiOZTujSg+WxMihSt4vla8Rqo++jneSvCiGc4xM16L6U5d1ZNfzbFdYe7rFke6d9RxNbPw8ZeR0eE/4EF+dUTdh8LA+hedfPwiSN+t5lVmx510VS6UTJycM/txBdYBMhLr9ypKcYBUIXBkMRGyQmYPkEHkUrXE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153290; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9eCj/NCScyqByJ/iYRppRDzEwAdB3DuVsfWQAxGoaj4=; b=ffpZ6GqfZbLh8acBY5raoko8DXMaLrxaW+x9lUBipCt5N26eCmhYi/ZWVBpPvpaAcKtRuxOCWfMZk5ducRaPCSXI+htQbRLsEHAuRXGypI8kfSud0YoTzA5YutkWDLhlllEVKvEDTI0gF3cw6wWmtZLLvtXMYYiImT9vLgoGnHk= 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 1694153290166826.323480714023; Thu, 7 Sep 2023 23:08:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUcn-0000G8-UE; Fri, 08 Sep 2023 02:05:49 -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 1qeUcg-00008T-7i for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:05:43 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUcc-0005ZB-Qr for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:05:41 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1c0db66af1bso12614575ad.2 for ; Thu, 07 Sep 2023 23:05:38 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.05.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:05:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153137; x=1694757937; 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=9eCj/NCScyqByJ/iYRppRDzEwAdB3DuVsfWQAxGoaj4=; b=BHn+5GflSmpEVDS7CXAPwsI2YjupKdABL+QCWvnRRA7gsqwgCrUmqQ6JXrKq01tyQE 48qASreQCVmtBf6BTmg0ZKWpED9e535AdhuKLgAkIREus2i2QK0q8lG9qkVilvFBpeU0 3E6aTEq/MfPvJuFkoyPoK2jry3k9ODhE/nNf5fVAoYbJrRBLjjeY333IH9PYAuxI3i8K WfEZSpgvYST2sKL0UyDOn14L98RmZjSdtvGiCH/1i6/pytKGN2FeQCZls7EQmXk9f1tg jvKaGHTT1OTx6IwragP6GsNzbFrAsXVi33i+jP3uI12euM6IvLQrbAhSx9J89oXCLZIN mplg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153137; x=1694757937; 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=9eCj/NCScyqByJ/iYRppRDzEwAdB3DuVsfWQAxGoaj4=; b=YzWLlMfW/89qGa9M8Eg6frCDYMs1KvtkLtOeX72J9RJk3XJzNFo21zjekyU6/iBxcT xmoafIgSp9VF84Uvw5mPnUMHyNLZYps2smk7Oa6qmbnH8oVxFn9O0Ho17i75dSkf3yBA BHAo7lS5ruolbmXDAdWZ5YKKo9QgLbrRt9xOW6ehnDfy5/wA2E28H5KqNikhMnNZzCil sUSiE7uOsMhFh4sFNClKqNkp0GJxRJxxLW+9YY+w/UuzmnuI3FfmDpTN69EOI7+ePtP9 wv5dh2B+pHqx4UJU8/KL1VkiBqCG/JRHw9gvzNW5WlfPQX86Mg1dp2u29DzoxA/dcUUO d9Dw== X-Gm-Message-State: AOJu0YzZsDmRfFk89c6e0kTGDrQYONH90HGanmmQNA/mRtKCzIlqJC3X QJo32uS0r2/9DueXHwjs593QjnWANSaTi4Vi X-Google-Smtp-Source: AGHT+IEc8Vg6WoutpS4Wtkibqz08a8SKcLqJTyQm7iabfWwMM3BTgRKxfCrm1tlh0W7uz8KwOw2i+Q== X-Received: by 2002:a17:902:e54b:b0:1b9:f7f4:5687 with SMTP id n11-20020a170902e54b00b001b9f7f45687mr2253325plf.24.1694153137180; Thu, 07 Sep 2023 23:05:37 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Lawrence Hunter , Nazar Kazakov , Max Chou , Alistair Francis Subject: [PULL 11/65] target/riscv: Add Zvbc ISA extension support Date: Fri, 8 Sep 2023 16:03:37 +1000 Message-ID: <20230908060431.1903919-12-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::632; envelope-from=alistair23@gmail.com; helo=mail-pl1-x632.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: 1694153290786100009 Content-Type: text/plain; charset="utf-8" From: Lawrence Hunter This commit adds support for the Zvbc vector-crypto extension, which consists of the following instructions: * vclmulh.[vx,vv] * vclmul.[vx,vv] Translation functions are defined in `target/riscv/insn_trans/trans_rvvk.c.inc` and helpers are defined in `target/riscv/vcrypto_helper.c`. Co-authored-by: Nazar Kazakov Co-authored-by: Max Chou Signed-off-by: Nazar Kazakov Signed-off-by: Lawrence Hunter Signed-off-by: Max Chou [max.chou@sifive.com: Exposed x-zvbc property] Message-ID: <20230711165917.2629866-5-max.chou@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/cpu_cfg.h | 1 + target/riscv/helper.h | 6 +++ target/riscv/insn32.decode | 6 +++ target/riscv/cpu.c | 9 ++++ target/riscv/translate.c | 1 + target/riscv/vcrypto_helper.c | 59 ++++++++++++++++++++++ target/riscv/insn_trans/trans_rvvk.c.inc | 62 ++++++++++++++++++++++++ target/riscv/meson.build | 3 +- 8 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 target/riscv/vcrypto_helper.c create mode 100644 target/riscv/insn_trans/trans_rvvk.c.inc diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h index 2bd9510ba3..d25b36a512 100644 --- a/target/riscv/cpu_cfg.h +++ b/target/riscv/cpu_cfg.h @@ -85,6 +85,7 @@ struct RISCVCPUConfig { bool ext_zve32f; bool ext_zve64f; bool ext_zve64d; + bool ext_zvbc; bool ext_zmmul; bool ext_zvfbfmin; bool ext_zvfbfwma; diff --git a/target/riscv/helper.h b/target/riscv/helper.h index c95adaf08a..6776777c4e 100644 --- a/target/riscv/helper.h +++ b/target/riscv/helper.h @@ -1182,3 +1182,9 @@ DEF_HELPER_5(vfwcvtbf16_f_f_v, void, ptr, ptr, ptr, e= nv, i32) =20 DEF_HELPER_6(vfwmaccbf16_vv, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vfwmaccbf16_vf, void, ptr, ptr, i64, ptr, env, i32) + +/* Vector crypto functions */ +DEF_HELPER_6(vclmul_vv, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vclmul_vx, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vclmulh_vv, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vclmulh_vx, void, ptr, ptr, tl, ptr, env, i32) diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode index e341fa9213..dd50d5a48c 100644 --- a/target/riscv/insn32.decode +++ b/target/riscv/insn32.decode @@ -946,3 +946,9 @@ vfwcvtbf16_f_f_v 010010 . ..... 01101 001 ..... 101011= 1 @r2_vm # *** Zvfbfwma Standard Extension *** vfwmaccbf16_vv 111011 . ..... ..... 001 ..... 1010111 @r_vm vfwmaccbf16_vf 111011 . ..... ..... 101 ..... 1010111 @r_vm + +# *** Zvbc vector crypto extension *** +vclmul_vv 001100 . ..... ..... 010 ..... 1010111 @r_vm +vclmul_vx 001100 . ..... ..... 110 ..... 1010111 @r_vm +vclmulh_vv 001101 . ..... ..... 010 ..... 1010111 @r_vm +vclmulh_vx 001101 . ..... ..... 110 ..... 1010111 @r_vm diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 921c19e6cd..f74e0926c2 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -120,6 +120,7 @@ static const struct isa_ext_data isa_edata_arr[] =3D { ISA_EXT_DATA_ENTRY(zksed, PRIV_VERSION_1_12_0, ext_zksed), ISA_EXT_DATA_ENTRY(zksh, PRIV_VERSION_1_12_0, ext_zksh), ISA_EXT_DATA_ENTRY(zkt, PRIV_VERSION_1_12_0, ext_zkt), + ISA_EXT_DATA_ENTRY(zvbc, PRIV_VERSION_1_12_0, ext_zvbc), ISA_EXT_DATA_ENTRY(zve32f, PRIV_VERSION_1_10_0, ext_zve32f), ISA_EXT_DATA_ENTRY(zve64f, PRIV_VERSION_1_10_0, ext_zve64f), ISA_EXT_DATA_ENTRY(zve64d, PRIV_VERSION_1_10_0, ext_zve64d), @@ -1271,6 +1272,11 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu= , Error **errp) return; } =20 + if (cpu->cfg.ext_zvbc && !cpu->cfg.ext_zve64f) { + error_setg(errp, "Zvbc extension requires V or Zve64{f,d} extensio= ns"); + return; + } + if (cpu->cfg.ext_zk) { cpu->cfg.ext_zkn =3D true; cpu->cfg.ext_zkr =3D true; @@ -1853,6 +1859,9 @@ static Property riscv_cpu_extensions[] =3D { DEFINE_PROP_BOOL("x-zvfbfmin", RISCVCPU, cfg.ext_zvfbfmin, false), DEFINE_PROP_BOOL("x-zvfbfwma", RISCVCPU, cfg.ext_zvfbfwma, false), =20 + /* Vector cryptography extensions */ + DEFINE_PROP_BOOL("x-zvbc", RISCVCPU, cfg.ext_zvbc, false), + DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 697df1be9e..7dbf173adb 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -1094,6 +1094,7 @@ static uint32_t opcode_at(DisasContextBase *dcbase, t= arget_ulong pc) #include "insn_trans/trans_rvzfa.c.inc" #include "insn_trans/trans_rvzfh.c.inc" #include "insn_trans/trans_rvk.c.inc" +#include "insn_trans/trans_rvvk.c.inc" #include "insn_trans/trans_privileged.c.inc" #include "insn_trans/trans_svinval.c.inc" #include "insn_trans/trans_rvbf16.c.inc" diff --git a/target/riscv/vcrypto_helper.c b/target/riscv/vcrypto_helper.c new file mode 100644 index 0000000000..8b7c63d499 --- /dev/null +++ b/target/riscv/vcrypto_helper.c @@ -0,0 +1,59 @@ +/* + * RISC-V Vector Crypto Extension Helpers for QEMU. + * + * Copyright (C) 2023 SiFive, Inc. + * Written by Codethink Ltd and SiFive. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2 or later, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License f= or + * more details. + * + * You should have received a copy of the GNU General Public License along= with + * this program. If not, see . + */ + +#include "qemu/osdep.h" +#include "qemu/host-utils.h" +#include "qemu/bitops.h" +#include "cpu.h" +#include "exec/memop.h" +#include "exec/exec-all.h" +#include "exec/helper-proto.h" +#include "internals.h" +#include "vector_internals.h" + +static uint64_t clmul64(uint64_t y, uint64_t x) +{ + uint64_t result =3D 0; + for (int j =3D 63; j >=3D 0; j--) { + if ((y >> j) & 1) { + result ^=3D (x << j); + } + } + return result; +} + +static uint64_t clmulh64(uint64_t y, uint64_t x) +{ + uint64_t result =3D 0; + for (int j =3D 63; j >=3D 1; j--) { + if ((y >> j) & 1) { + result ^=3D (x >> (64 - j)); + } + } + return result; +} + +RVVCALL(OPIVV2, vclmul_vv, OP_UUU_D, H8, H8, H8, clmul64) +GEN_VEXT_VV(vclmul_vv, 8) +RVVCALL(OPIVX2, vclmul_vx, OP_UUU_D, H8, H8, clmul64) +GEN_VEXT_VX(vclmul_vx, 8) +RVVCALL(OPIVV2, vclmulh_vv, OP_UUU_D, H8, H8, H8, clmulh64) +GEN_VEXT_VV(vclmulh_vv, 8) +RVVCALL(OPIVX2, vclmulh_vx, OP_UUU_D, H8, H8, clmulh64) +GEN_VEXT_VX(vclmulh_vx, 8) diff --git a/target/riscv/insn_trans/trans_rvvk.c.inc b/target/riscv/insn_t= rans/trans_rvvk.c.inc new file mode 100644 index 0000000000..552b08a2fd --- /dev/null +++ b/target/riscv/insn_trans/trans_rvvk.c.inc @@ -0,0 +1,62 @@ +/* + * RISC-V translation routines for the vector crypto extension. + * + * Copyright (C) 2023 SiFive, Inc. + * Written by Codethink Ltd and SiFive. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2 or later, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License f= or + * more details. + * + * You should have received a copy of the GNU General Public License along= with + * this program. If not, see . + */ + +/* + * Zvbc + */ + +#define GEN_VV_MASKED_TRANS(NAME, CHECK) \ + static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ + { \ + if (CHECK(s, a)) { \ + return opivv_trans(a->rd, a->rs1, a->rs2, a->vm, \ + gen_helper_##NAME, s); \ + } \ + return false; \ + } + +static bool vclmul_vv_check(DisasContext *s, arg_rmrr *a) +{ + return opivv_check(s, a) && + s->cfg_ptr->ext_zvbc =3D=3D true && + s->sew =3D=3D MO_64; +} + +GEN_VV_MASKED_TRANS(vclmul_vv, vclmul_vv_check) +GEN_VV_MASKED_TRANS(vclmulh_vv, vclmul_vv_check) + +#define GEN_VX_MASKED_TRANS(NAME, CHECK) \ + static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ + { \ + if (CHECK(s, a)) { \ + return opivx_trans(a->rd, a->rs1, a->rs2, a->vm, \ + gen_helper_##NAME, s); \ + } \ + return false; \ + } + +static bool vclmul_vx_check(DisasContext *s, arg_rmrr *a) +{ + return opivx_check(s, a) && + s->cfg_ptr->ext_zvbc =3D=3D true && + s->sew =3D=3D MO_64; +} + +GEN_VX_MASKED_TRANS(vclmul_vx, vclmul_vx_check) +GEN_VX_MASKED_TRANS(vclmulh_vx, vclmul_vx_check) diff --git a/target/riscv/meson.build b/target/riscv/meson.build index c3801ee5e0..660078bda1 100644 --- a/target/riscv/meson.build +++ b/target/riscv/meson.build @@ -21,7 +21,8 @@ riscv_ss.add(files( 'translate.c', 'm128_helper.c', 'crypto_helper.c', - 'zce_helper.c' + 'zce_helper.c', + 'vcrypto_helper.c' )) riscv_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c'), if_false: files(= 'kvm-stub.c')) =20 --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153196; cv=none; d=zohomail.com; s=zohoarc; b=kPDTTf1hHbZYBwQfC5NlQHD1yhgnwHzxz9fuf6HdQYGbYc3+tGif4Y42t/Nqk4KZIPY/L/8PJNNLquautC996jiIQMzPaifTei8NiSGX9fLxtvK+LWdimoRHLozICwhCiCHDSZXIEGq+rSy1QxWSY76YGWxfrMFjuhG/PDBefLw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153196; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fmxtFBhMNKgAclVFCJgIRWOiSmo6h51x/2XzyTwE3NU=; b=MQv3kDu+YqLQkvSxKE4MKLjzxW111ISaleWTG7jO4R0uhJKHGq9NQGiyurFKBLskypZnDuF1qMqfAzCc/MkmRp3oRKiBKXM2mAqJJ98w/DQyDPYhAJ0D6oVLdLnBrDsq3Y3BmT9vx5VMzyv+WzBZ7hJDloegCrONv0Tn2JUdXbY= 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 1694153196490664.8837021670962; Thu, 7 Sep 2023 23:06:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUcm-0000Gt-4V; Fri, 08 Sep 2023 02:05:48 -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 1qeUcj-0000DR-Bb for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:05:45 -0400 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 1qeUcg-0005Zn-Vp for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:05:45 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1bc8a2f71eeso14841555ad.0 for ; Thu, 07 Sep 2023 23:05:42 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.05.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:05:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153141; x=1694757941; 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=fmxtFBhMNKgAclVFCJgIRWOiSmo6h51x/2XzyTwE3NU=; b=E7BPykYoX5iT4QEB1DXAiLP7IcklVrLvVgkZdXog5uOkzlerG6jwRgJk8CMQeEYrue q5bLWAU/x7oOGIefpkSMySrK9bjkdLwD2tzT3zeGjk/vCt7UNEq6OadQteBu2LSJBo/Z JiQRb03HVidKiJ9ZuGcfuLpPulz1IAHr3aE4TPaT5fZKMkpgtHscBAyckKxtBO3M/4wj /Tdy6tTW4KTduaYRrNTIJ290GGn7Z7UleV1hzt4ib+kClu6H6vEgo+5w4fQ2P28QAOWv X0M61IaG8DjA4K7eQ9RYmc03Q7JC+2UP2f62aTvQYLisSDWvKVNDJzm6oVlXrtNm4YZe HGaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153141; x=1694757941; 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=fmxtFBhMNKgAclVFCJgIRWOiSmo6h51x/2XzyTwE3NU=; b=FLUX/e0J0miLiYJ2EvHhXMoZIXl2fvtz0w+6K5ALUTYuTRHzZmWw++MwtP7TO7iC8W lOCwgs41tSMeNrA9flFlCnqBHqhNG7wnA+4e7jGY9qCc19150FFQiHmlqSa/wXMyGfKp W+3mCIrVtbS1BNGVTeDuglBTN2GB8pUb5aMTWeqR/y6PEAZc2JN11y80LqM7TrCf3//z 86QG1hQiXe/kulldeGEq5DnHe1Jv8QOoqlP6VWelnk2G1mgxIaT3fOGYqLGfd0d2wF6h 60WI69+yGtGgsDAnztEernEs1PbUeEbS2XikOIm/At63gBw7yBdYu5F6Qu0I/mzwPIvh FqzQ== X-Gm-Message-State: AOJu0YwYwbJnqykLDhqCPGYz+unUvp5T9wmcXJMCiJkM8c5KgQkxJHlI RRjru6zFKusClQ6uiaWR84945k5xIGPudhS/ X-Google-Smtp-Source: AGHT+IFLp2ZnplWZ5yJuV1DbIJWm5KM0iGJcioXLnMJ3GwFLD4r/EpbWW3OXXqB3CnLr3Q2p6Ea92w== X-Received: by 2002:a17:902:b497:b0:1c3:61d9:2b32 with SMTP id y23-20020a170902b49700b001c361d92b32mr1400350plr.45.1694153141395; Thu, 07 Sep 2023 23:05:41 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Nazar Kazakov , Richard Henderson , Weiwei Li , Max Chou , Alistair Francis Subject: [PULL 12/65] target/riscv: Move vector translation checks Date: Fri, 8 Sep 2023 16:03:38 +1000 Message-ID: <20230908060431.1903919-13-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::62f; envelope-from=alistair23@gmail.com; helo=mail-pl1-x62f.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: 1694153198551100005 Content-Type: text/plain; charset="utf-8" From: Nazar Kazakov Move the checks out of `do_opiv{v,x,i}_gvec{,_shift}` functions and into the corresponding macros. This enables the functions to be reused in proceeding commits without check duplication. Signed-off-by: Nazar Kazakov Reviewed-by: Richard Henderson Reviewed-by: Weiwei Li Signed-off-by: Max Chou Message-ID: <20230711165917.2629866-6-max.chou@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/insn_trans/trans_rvv.c.inc | 28 +++++++++++-------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_tr= ans/trans_rvv.c.inc index 7e194aae34..5dfd524c7d 100644 --- a/target/riscv/insn_trans/trans_rvv.c.inc +++ b/target/riscv/insn_trans/trans_rvv.c.inc @@ -1183,9 +1183,6 @@ do_opivv_gvec(DisasContext *s, arg_rmrr *a, GVecGen3F= n *gvec_fn, gen_helper_gvec_4_ptr *fn) { TCGLabel *over =3D gen_new_label(); - if (!opivv_check(s, a)) { - return false; - } =20 tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); =20 @@ -1218,6 +1215,9 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a= ) \ gen_helper_##NAME##_b, gen_helper_##NAME##_h, \ gen_helper_##NAME##_w, gen_helper_##NAME##_d, \ }; \ + if (!opivv_check(s, a)) { \ + return false; \ + } \ return do_opivv_gvec(s, a, tcg_gen_gvec_##SUF, fns[s->sew]); \ } =20 @@ -1276,10 +1276,6 @@ static inline bool do_opivx_gvec(DisasContext *s, arg_rmrr *a, GVecGen2sFn *gvec_fn, gen_helper_opivx *fn) { - if (!opivx_check(s, a)) { - return false; - } - if (a->vm && s->vl_eq_vlmax && !(s->vta && s->lmul < 0)) { TCGv_i64 src1 =3D tcg_temp_new_i64(); =20 @@ -1301,6 +1297,9 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a= ) \ gen_helper_##NAME##_b, gen_helper_##NAME##_h, \ gen_helper_##NAME##_w, gen_helper_##NAME##_d, \ }; \ + if (!opivx_check(s, a)) { \ + return false; \ + } \ return do_opivx_gvec(s, a, tcg_gen_gvec_##SUF, fns[s->sew]); \ } =20 @@ -1432,10 +1431,6 @@ static inline bool do_opivi_gvec(DisasContext *s, arg_rmrr *a, GVecGen2iFn *gvec_fn, gen_helper_opivx *fn, imm_mode_t imm_mode) { - if (!opivx_check(s, a)) { - return false; - } - if (a->vm && s->vl_eq_vlmax && !(s->vta && s->lmul < 0)) { gvec_fn(s->sew, vreg_ofs(s, a->rd), vreg_ofs(s, a->rs2), extract_imm(s, a->rs1, imm_mode), MAXSZ(s), MAXSZ(s)); @@ -1453,6 +1448,9 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a= ) \ gen_helper_##OPIVX##_b, gen_helper_##OPIVX##_h, \ gen_helper_##OPIVX##_w, gen_helper_##OPIVX##_d, \ }; \ + if (!opivx_check(s, a)) { \ + return false; \ + } \ return do_opivi_gvec(s, a, tcg_gen_gvec_##SUF, \ fns[s->sew], IMM_MODE); \ } @@ -1775,10 +1773,6 @@ static inline bool do_opivx_gvec_shift(DisasContext *s, arg_rmrr *a, GVecGen2sFn32 *gvec_fn, gen_helper_opivx *fn) { - if (!opivx_check(s, a)) { - return false; - } - if (a->vm && s->vl_eq_vlmax && !(s->vta && s->lmul < 0)) { TCGv_i32 src1 =3D tcg_temp_new_i32(); =20 @@ -1800,7 +1794,9 @@ static bool trans_##NAME(DisasContext *s, arg_rmrr *a= ) \ gen_helper_##NAME##_b, gen_helper_##NAME##_h, \ gen_helper_##NAME##_w, gen_helper_##NAME##_d, \ }; \ - \ + if (!opivx_check(s, a)) { \ + return false; \ + } \ return do_opivx_gvec_shift(s, a, tcg_gen_gvec_##SUF, fns[s->sew]); \ } =20 --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153682; cv=none; d=zohomail.com; s=zohoarc; b=i7KJPDkopv2xXqP77QixJZU7fjaG/nsDm850LoMa/QO0veKWpD8FIejdAEK+mEs5IjxQ7Qi6KXI9CKqBFiQFG1YSHh7kIvPv9xxAk8sCBbXmUFYK9Yai+8PfTpE6nJoR0z9hh1XEgDDCn/OA6wMKPurlem/KeDmniL+ArBjLwNA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153682; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qepJics0tn9vo/6916LL1wFiawsxHmg1P1pjmA4MfdI=; b=dG7f8gj7oWYvWsas0CKW24joX9Ny16Ni/9PmZhhazbZmP3Cuww+KxqWPm9oEm6qK99YZmB7J3A9grCYIn88JA3gRnzIqjZ2YEUbzL6YOw0mT0HRJZxgat3wS1DljyaaE2uah3N8qM7YHkHWhDd2FttbX9KSCWdJ7wzAZx/VQVjA= 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 1694153682002964.9140578044888; Thu, 7 Sep 2023 23:14:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUcp-0000LV-Iz; Fri, 08 Sep 2023 02:05:51 -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 1qeUco-0000Ka-5P for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:05:50 -0400 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 1qeUcl-0005bK-Nz for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:05:49 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1c1e3a4a06fso13413035ad.3 for ; Thu, 07 Sep 2023 23:05:46 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.05.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:05:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153145; x=1694757945; 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=qepJics0tn9vo/6916LL1wFiawsxHmg1P1pjmA4MfdI=; b=pwEP/HGMqOCi0T51zz6yPVNaIqIHZQu1HNGqa0NJnVi37WVbiDpGf+eKl0Ggb9EdrI Rx+pK+JMtgPhULqaX2FTiyRwvKbjaQtJzPQrOPvfTJP28drG4R1auaNSHMCZHTJ9zs+v iRsTwRZ1M8RNpbxP9F/Kk/1qb0OZau2UtdCtISX1EkqAcxGvPN8tluvfUH+9BGca8aFe 9lbYPLJXzWIuc0a2poKUAp1sPKmWKdgww/T0jSs75pUrXjOqp2+r/UeHMXCIQ+VmQ/tT LaKDJkQLRKP/8jVK+ztqwgC8GnjvyWgwvreN5RvMOm8jqBAhElpUHIS+GJFHvjF78hla dJSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153145; x=1694757945; 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=qepJics0tn9vo/6916LL1wFiawsxHmg1P1pjmA4MfdI=; b=X8l7A+tBLz5atYovzJITgto5PoFrw7SZCdy5PJH0HxWv4vvnb1Tajwidb0wLI/0keA dEqv89CfSxvCGcX3dQhT6+n9JkcDNkcHfNhuDRlsrnH0CM0pP1ZOayohAdXETxG+ybl2 M+jHnnt9j37LrZOMuF0cSDpLTQiXZO06TXINhoucCV8bG/aYNimcEiDX25ODinJ32kLa a93FnozKK0sOC2sDZRUY552bYsXyM5b0BTvnJY9xjekn/JnOmx4tCOLXEa1nkH6OyByX afZwoKhnniBfquV3xKKmdObslQx0Zu9s8vTsnTeC66FXqJNAFw6AXln8o012bPQWnLpD e2Rg== X-Gm-Message-State: AOJu0YyzzXN3fae8ZDlXvELRELaaTETpwmdYf8irpcBz7v+vr+rktsy+ bFN584MDvroLPW3XyvOq6VnZJOTekfzj4Gnz X-Google-Smtp-Source: AGHT+IHAp0kRiFQy7dc9doY79PFw1DvRwh+zwCAS7g2/kKos4dtRUMGTwGvLS/1K7sYrPvzMymg70Q== X-Received: by 2002:a17:902:bcc6:b0:1bf:25a0:f875 with SMTP id o6-20020a170902bcc600b001bf25a0f875mr1371125pls.39.1694153145401; Thu, 07 Sep 2023 23:05:45 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Dickon Hood , Richard Henderson , Weiwei Li , Max Chou , Alistair Francis Subject: [PULL 13/65] target/riscv: Refactor translation of vector-widening instruction Date: Fri, 8 Sep 2023 16:03:39 +1000 Message-ID: <20230908060431.1903919-14-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::634; envelope-from=alistair23@gmail.com; helo=mail-pl1-x634.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: 1694153682757100002 Content-Type: text/plain; charset="utf-8" From: Dickon Hood Zvbb (implemented in later commit) has a widening instruction, which requires an extra check on the enabled extensions. Refactor GEN_OPIVX_WIDEN_TRANS() to take a check function to avoid reimplementing it. Signed-off-by: Dickon Hood Reviewed-by: Richard Henderson Reviewed-by: Weiwei Li Signed-off-by: Max Chou Message-ID: <20230711165917.2629866-7-max.chou@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/insn_trans/trans_rvv.c.inc | 52 +++++++++++-------------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_tr= ans/trans_rvv.c.inc index 5dfd524c7d..a556250553 100644 --- a/target/riscv/insn_trans/trans_rvv.c.inc +++ b/target/riscv/insn_trans/trans_rvv.c.inc @@ -1526,30 +1526,24 @@ static bool opivx_widen_check(DisasContext *s, arg_= rmrr *a) vext_check_ds(s, a->rd, a->rs2, a->vm); } =20 -static bool do_opivx_widen(DisasContext *s, arg_rmrr *a, - gen_helper_opivx *fn) -{ - if (opivx_widen_check(s, a)) { - return opivx_trans(a->rd, a->rs1, a->rs2, a->vm, fn, s); - } - return false; -} - -#define GEN_OPIVX_WIDEN_TRANS(NAME) \ -static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ -{ \ - static gen_helper_opivx * const fns[3] =3D { \ - gen_helper_##NAME##_b, \ - gen_helper_##NAME##_h, \ - gen_helper_##NAME##_w \ - }; \ - return do_opivx_widen(s, a, fns[s->sew]); \ +#define GEN_OPIVX_WIDEN_TRANS(NAME, CHECK) \ +static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ +{ \ + if (CHECK(s, a)) { \ + static gen_helper_opivx * const fns[3] =3D { = \ + gen_helper_##NAME##_b, \ + gen_helper_##NAME##_h, \ + gen_helper_##NAME##_w \ + }; \ + return opivx_trans(a->rd, a->rs1, a->rs2, a->vm, fns[s->sew], s); \ + } \ + return false; \ } =20 -GEN_OPIVX_WIDEN_TRANS(vwaddu_vx) -GEN_OPIVX_WIDEN_TRANS(vwadd_vx) -GEN_OPIVX_WIDEN_TRANS(vwsubu_vx) -GEN_OPIVX_WIDEN_TRANS(vwsub_vx) +GEN_OPIVX_WIDEN_TRANS(vwaddu_vx, opivx_widen_check) +GEN_OPIVX_WIDEN_TRANS(vwadd_vx, opivx_widen_check) +GEN_OPIVX_WIDEN_TRANS(vwsubu_vx, opivx_widen_check) +GEN_OPIVX_WIDEN_TRANS(vwsub_vx, opivx_widen_check) =20 /* WIDEN OPIVV with WIDEN */ static bool opiwv_widen_check(DisasContext *s, arg_rmrr *a) @@ -1997,9 +1991,9 @@ GEN_OPIVX_TRANS(vrem_vx, opivx_check) GEN_OPIVV_WIDEN_TRANS(vwmul_vv, opivv_widen_check) GEN_OPIVV_WIDEN_TRANS(vwmulu_vv, opivv_widen_check) GEN_OPIVV_WIDEN_TRANS(vwmulsu_vv, opivv_widen_check) -GEN_OPIVX_WIDEN_TRANS(vwmul_vx) -GEN_OPIVX_WIDEN_TRANS(vwmulu_vx) -GEN_OPIVX_WIDEN_TRANS(vwmulsu_vx) +GEN_OPIVX_WIDEN_TRANS(vwmul_vx, opivx_widen_check) +GEN_OPIVX_WIDEN_TRANS(vwmulu_vx, opivx_widen_check) +GEN_OPIVX_WIDEN_TRANS(vwmulsu_vx, opivx_widen_check) =20 /* Vector Single-Width Integer Multiply-Add Instructions */ GEN_OPIVV_TRANS(vmacc_vv, opivv_check) @@ -2015,10 +2009,10 @@ GEN_OPIVX_TRANS(vnmsub_vx, opivx_check) GEN_OPIVV_WIDEN_TRANS(vwmaccu_vv, opivv_widen_check) GEN_OPIVV_WIDEN_TRANS(vwmacc_vv, opivv_widen_check) GEN_OPIVV_WIDEN_TRANS(vwmaccsu_vv, opivv_widen_check) -GEN_OPIVX_WIDEN_TRANS(vwmaccu_vx) -GEN_OPIVX_WIDEN_TRANS(vwmacc_vx) -GEN_OPIVX_WIDEN_TRANS(vwmaccsu_vx) -GEN_OPIVX_WIDEN_TRANS(vwmaccus_vx) +GEN_OPIVX_WIDEN_TRANS(vwmaccu_vx, opivx_widen_check) +GEN_OPIVX_WIDEN_TRANS(vwmacc_vx, opivx_widen_check) +GEN_OPIVX_WIDEN_TRANS(vwmaccsu_vx, opivx_widen_check) +GEN_OPIVX_WIDEN_TRANS(vwmaccus_vx, opivx_widen_check) =20 /* Vector Integer Merge and Move Instructions */ static bool trans_vmv_v_v(DisasContext *s, arg_vmv_v_v *a) --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153176; cv=none; d=zohomail.com; s=zohoarc; b=QzCYo+DXnFidfpz/TBpaVkGBYi+Kcg9/Dew9BpcdiSj9JZIHC8j4/bv6kkjEan4AVFTES8Ly599tfGff1/HHThEFGGixxW5lSkdfE9V+63rMMVh0S6Trlx4sv985HG9DSqY5UTe4N7CGTatkAwWjsh6kD3cqhfEtY5suXj/vz5I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153176; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KCzcagA45q4P5ZXNWFhRkkRERr88WEyNrG4CtwWBxb4=; b=lOKGBhK3MFTpt++v4XBBz3IRf2tspI+YiAfeT8q2bkDF6VhsJJZ4otqai/IbXwNS5IwPSqKNVEf5gag1liTG9A/jV0ZClfwcdLtbQaGVjJFplTynjhCuz5XXGVnBsyEQkRrU7dQGGWf66GhKuGDWxhsQmO4xZLgVtKGniH8q+pE= 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 1694153176696233.96666374733002; Thu, 7 Sep 2023 23:06:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUcv-0000OZ-P8; Fri, 08 Sep 2023 02:05:57 -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 1qeUcs-0000OC-IL for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:05:54 -0400 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 1qeUcq-0005cd-27 for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:05:54 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1bf11b1c7d0so20391405ad.0 for ; Thu, 07 Sep 2023 23:05:50 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.05.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:05:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153149; x=1694757949; 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=KCzcagA45q4P5ZXNWFhRkkRERr88WEyNrG4CtwWBxb4=; b=XiibFezJYpD9lVX9g4Ni2RQzAuczkdAUfyLecXhjefYPORgmwWEopeho7jFuf9+eDj KA08Nt/IEA86+asb4dQpe+Qglxurp3ud4V/ytSYdVCfnvBUgvsN815XDMIF8e6eH+lal jSwQ04xPz8o0eUq23A8z26GVy7tDG2l8LOeUJAnIEu3wBRvsgfgJ6hPyCWv/QbLMDsnn YS+kO13DzHU5VwnufkNU6wb3qUpXvFL9F223kVk4Xu5c3+S4Hr+I4YwvuXcbGnNB0t4D e1SfAqkh8BMsejobEPCC0LVMzxxH5k5SWSxQtSS4CEFTzb3cV7NoJ7OyTsgfW4f1GhKA 3qrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153149; x=1694757949; 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=KCzcagA45q4P5ZXNWFhRkkRERr88WEyNrG4CtwWBxb4=; b=qAjztDGJyR0IR9YmEYCCsakNyxCueeiD8dfMY2GHeT3C5rkcMp5y+jOiE6L2V+x4sk chN8kGpHssvF5xBr0wfqKnzpnY/Ki2WPoLF8MScaMlE+8TjQkweCPo1Bw30Rzi9LYEAU CHorGWO4zfHijVoUOMju9xyHwqa4FYmM8WGjTUo3q0tJxjX2YiOg7uJTbRvahFZmhF/Y D4QMxt7HVoEe1MuztqFhE7huhIy93xi4FSr/bRW4x7jzihVPCaZiTN9sWrqpE0rTuUeP HZ31XxkPCLzXfHy9hmLdJy/O2rQnwT9PulHytpSE5NkUlgjW7Emc0Kbcr9ENAEzuvfiQ TJaw== X-Gm-Message-State: AOJu0Yy6n8F9skwFVWjaWzYfdcnK+jjcU7LYJywKft/ZzF4dfmddQVxm s/jtTVu8lv6mjuY+MgVtWpCfaxLAYwkLMfNs X-Google-Smtp-Source: AGHT+IEI/DpLiS0G94CjwiKkFJXB7mNDCOrexZoobo/7JmAOG+pVHCGfHYKB0lWz3CVrmfIixSJ/Qw== X-Received: by 2002:a17:90a:2f65:b0:273:83ac:5eb9 with SMTP id s92-20020a17090a2f6500b0027383ac5eb9mr6173967pjd.4.1694153149049; Thu, 07 Sep 2023 23:05:49 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Kiran Ostrolenk , Weiwei Li , Max Chou , Alistair Francis Subject: [PULL 14/65] target/riscv: Refactor some of the generic vector functionality Date: Fri, 8 Sep 2023 16:03:40 +1000 Message-ID: <20230908060431.1903919-15-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::631; envelope-from=alistair23@gmail.com; helo=mail-pl1-x631.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: 1694153179160100006 Content-Type: text/plain; charset="utf-8" From: Kiran Ostrolenk Move some macros out of `vector_helper` and into `vector_internals`. This ensures they can be used by both vector and vector-crypto helpers (latter implemented in proceeding commits). Signed-off-by: Kiran Ostrolenk Reviewed-by: Weiwei Li Signed-off-by: Max Chou Message-ID: <20230711165917.2629866-8-max.chou@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/vector_internals.h | 46 +++++++++++++++++++++++++++++++++ target/riscv/vector_helper.c | 42 ------------------------------ 2 files changed, 46 insertions(+), 42 deletions(-) diff --git a/target/riscv/vector_internals.h b/target/riscv/vector_internal= s.h index 749d138beb..8133111e5f 100644 --- a/target/riscv/vector_internals.h +++ b/target/riscv/vector_internals.h @@ -121,12 +121,52 @@ void vext_set_elems_1s(void *base, uint32_t is_agnost= ic, uint32_t cnt, /* expand macro args before macro */ #define RVVCALL(macro, ...) macro(__VA_ARGS__) =20 +/* (TD, T2, TX2) */ +#define OP_UU_B uint8_t, uint8_t, uint8_t +#define OP_UU_H uint16_t, uint16_t, uint16_t +#define OP_UU_W uint32_t, uint32_t, uint32_t +#define OP_UU_D uint64_t, uint64_t, uint64_t + /* (TD, T1, T2, TX1, TX2) */ #define OP_UUU_B uint8_t, uint8_t, uint8_t, uint8_t, uint8_t #define OP_UUU_H uint16_t, uint16_t, uint16_t, uint16_t, uint16_t #define OP_UUU_W uint32_t, uint32_t, uint32_t, uint32_t, uint32_t #define OP_UUU_D uint64_t, uint64_t, uint64_t, uint64_t, uint64_t =20 +#define OPIVV1(NAME, TD, T2, TX2, HD, HS2, OP) \ +static void do_##NAME(void *vd, void *vs2, int i) \ +{ \ + TX2 s2 =3D *((T2 *)vs2 + HS2(i)); \ + *((TD *)vd + HD(i)) =3D OP(s2); \ +} + +#define GEN_VEXT_V(NAME, ESZ) \ +void HELPER(NAME)(void *vd, void *v0, void *vs2, \ + CPURISCVState *env, uint32_t desc) \ +{ \ + uint32_t vm =3D vext_vm(desc); \ + uint32_t vl =3D env->vl; \ + uint32_t total_elems =3D \ + vext_get_total_elems(env, desc, ESZ); \ + uint32_t vta =3D vext_vta(desc); \ + uint32_t vma =3D vext_vma(desc); \ + uint32_t i; \ + \ + for (i =3D env->vstart; i < vl; i++) { \ + if (!vm && !vext_elem_mask(v0, i)) { \ + /* set masked-off elements to 1s */ \ + vext_set_elems_1s(vd, vma, i * ESZ, \ + (i + 1) * ESZ); \ + continue; \ + } \ + do_##NAME(vd, vs2, i); \ + } \ + env->vstart =3D 0; \ + /* set tail elements to 1s */ \ + vext_set_elems_1s(vd, vta, vl * ESZ, \ + total_elems * ESZ); \ +} + /* operation of two vector elements */ typedef void opivv2_fn(void *vd, void *vs1, void *vs2, int i); =20 @@ -179,4 +219,10 @@ void HELPER(NAME)(void *vd, void *v0, target_ulong s1,= \ do_##NAME, ESZ); \ } =20 +/* Three of the widening shortening macros: */ +/* (TD, T1, T2, TX1, TX2) */ +#define WOP_UUU_B uint16_t, uint8_t, uint8_t, uint16_t, uint16_t +#define WOP_UUU_H uint32_t, uint16_t, uint16_t, uint32_t, uint32_t +#define WOP_UUU_W uint64_t, uint32_t, uint32_t, uint64_t, uint64_t + #endif /* TARGET_RISCV_VECTOR_INTERNALS_H */ diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c index 1f29236a63..3fb05cc3d6 100644 --- a/target/riscv/vector_helper.c +++ b/target/riscv/vector_helper.c @@ -636,9 +636,6 @@ GEN_VEXT_ST_WHOLE(vs8r_v, int8_t, ste_b) #define OP_SUS_H int16_t, uint16_t, int16_t, uint16_t, int16_t #define OP_SUS_W int32_t, uint32_t, int32_t, uint32_t, int32_t #define OP_SUS_D int64_t, uint64_t, int64_t, uint64_t, int64_t -#define WOP_UUU_B uint16_t, uint8_t, uint8_t, uint16_t, uint16_t -#define WOP_UUU_H uint32_t, uint16_t, uint16_t, uint32_t, uint32_t -#define WOP_UUU_W uint64_t, uint32_t, uint32_t, uint64_t, uint64_t #define WOP_SSS_B int16_t, int8_t, int8_t, int16_t, int16_t #define WOP_SSS_H int32_t, int16_t, int16_t, int32_t, int32_t #define WOP_SSS_W int64_t, int32_t, int32_t, int64_t, int64_t @@ -3438,11 +3435,6 @@ GEN_VEXT_VF(vfwnmsac_vf_h, 4) GEN_VEXT_VF(vfwnmsac_vf_w, 8) =20 /* Vector Floating-Point Square-Root Instruction */ -/* (TD, T2, TX2) */ -#define OP_UU_H uint16_t, uint16_t, uint16_t -#define OP_UU_W uint32_t, uint32_t, uint32_t -#define OP_UU_D uint64_t, uint64_t, uint64_t - #define OPFVV1(NAME, TD, T2, TX2, HD, HS2, OP) \ static void do_##NAME(void *vd, void *vs2, int i, \ CPURISCVState *env) \ @@ -4139,40 +4131,6 @@ GEN_VEXT_CMP_VF(vmfge_vf_w, uint32_t, H4, vmfge32) GEN_VEXT_CMP_VF(vmfge_vf_d, uint64_t, H8, vmfge64) =20 /* Vector Floating-Point Classify Instruction */ -#define OPIVV1(NAME, TD, T2, TX2, HD, HS2, OP) \ -static void do_##NAME(void *vd, void *vs2, int i) \ -{ \ - TX2 s2 =3D *((T2 *)vs2 + HS2(i)); \ - *((TD *)vd + HD(i)) =3D OP(s2); \ -} - -#define GEN_VEXT_V(NAME, ESZ) \ -void HELPER(NAME)(void *vd, void *v0, void *vs2, \ - CPURISCVState *env, uint32_t desc) \ -{ \ - uint32_t vm =3D vext_vm(desc); \ - uint32_t vl =3D env->vl; \ - uint32_t total_elems =3D \ - vext_get_total_elems(env, desc, ESZ); \ - uint32_t vta =3D vext_vta(desc); \ - uint32_t vma =3D vext_vma(desc); \ - uint32_t i; \ - \ - for (i =3D env->vstart; i < vl; i++) { \ - if (!vm && !vext_elem_mask(v0, i)) { \ - /* set masked-off elements to 1s */ \ - vext_set_elems_1s(vd, vma, i * ESZ, \ - (i + 1) * ESZ); \ - continue; \ - } \ - do_##NAME(vd, vs2, i); \ - } \ - env->vstart =3D 0; \ - /* set tail elements to 1s */ \ - vext_set_elems_1s(vd, vta, vl * ESZ, \ - total_elems * ESZ); \ -} - target_ulong fclass_h(uint64_t frs1) { float16 f =3D frs1; --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153238; cv=none; d=zohomail.com; s=zohoarc; b=SrwPO9AefNTxNzMgqnCti/peY00XNWqQ25F+6ri7/WZVDHvUdJYdkEeW8hDsDM6ndzfquf4C6O5IVhgUSfVTZNPVMwJMq15d6aZ3RnKp3QVW7QBFmB6PbalRrb2IVXMZgHtwOpK5QHtuWp9TaEsnyfqmsmj7Fdo/zx8fqGbRtxU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153238; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xoSFwtuFhZkWGmCcMsedigUW2QpAqxRib5e5PEzJ78c=; b=Q3teFo3hbZlC8oHq9LfCEyT7VTXg4QbBg6CWwTusJQTIqnDhRg2brSfxGMlQ9Nu8Xsi6eOT5L+teEoDA58usE978IEFE4v2KDiKxFT+vE5laUE5bTIpZGN1NnSrf/GCyv9bcrGRCD9xuUjUsvOCfMvpFBjLFdFbC4Ll5aHFeTwE= 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 169415323886217.24446799854195; Thu, 7 Sep 2023 23:07:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUdC-0000tk-JS; Fri, 08 Sep 2023 02:06:18 -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 1qeUcx-0000ZN-3F for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:05:59 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUct-0005h2-IF for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:05:58 -0400 Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-273e1aec35aso52022a91.1 for ; Thu, 07 Sep 2023 23:05:55 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.05.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:05:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153154; x=1694757954; 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=xoSFwtuFhZkWGmCcMsedigUW2QpAqxRib5e5PEzJ78c=; b=eplmiRLaALbdFaA/dhT3EFlrg3xOb9oLEkV0d5W60QhUZ3NtzCfpLsyZNqPvVT3vBF QwrZvxJXQVu/dPimq1yyy468ZM8TcXNXNFUWxDCpyb4ryLLbuuCsyRGKqdRhhE+6KQaQ ng9L1orS/Yz+RQoFMSMizQ+BjaJYVJOQ6SFHWA1NyPwBcIJZs1biyrV1wcqaQD9GDcDG wlNGMPEHZr85VA+l7Bv4h+I3tIJmMTv0yKZHEJ9Fl5ymXy6zAY7Q9veE7h1XQXPAhUVb 8XCqgKNs2OqnEPJ9dcNYITck22XStL0bYkjuQECA9yOSaRBdJiGoH2yMDOvwZuArkKPi /+iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153154; x=1694757954; 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=xoSFwtuFhZkWGmCcMsedigUW2QpAqxRib5e5PEzJ78c=; b=nrMcfI4snTC5vBGmMXwK2pBKaTXGm5HlzW75QTMYi6rfsLLYl0MYJKzn7cE73UZ4ln lU++X/xCXS+pHHYpd1vVybBZBbC3Y+MDIHPR69I2cesQwSvQZL1C+cnlu7Bk3KvB3uiS joGKGYs5iwHUf56zdTI+1nQ7Rpu+gv+ECAOLW7DpU+nQAQRCwTR6JrEFBqiLTZj/0XcN juXXd09COHaLSFFGd2dUcZ3okbB0TskXIoa8x+t61pTOMWbHlR37O8mDWMUuyRla/8g2 iMUTAYTBefoEjA9Y6r95fTVfGQeI/hfVH4vl9PfQg0IJ9eiZddbjQxDpZn9Fehf2x4Jj wZyw== X-Gm-Message-State: AOJu0YzSq3sx/Xvpjgx3ZKLJcvkjsCgocPTIQNqS5R8a7x7m7hSXk4nU wuZcxUo9SAD5SaiRifJbiNAMKxEiEmei7rF0 X-Google-Smtp-Source: AGHT+IH2JKoi+xLmJlWbDpAOowrIQlyjEff+JUWAqj4hHCApLrqP2cs/rAujq1mAOpc6HKgznb6Qgg== X-Received: by 2002:a17:90b:8c5:b0:26b:3f10:820f with SMTP id ds5-20020a17090b08c500b0026b3f10820fmr1667991pjb.36.1694153153570; Thu, 07 Sep 2023 23:05:53 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Dickon Hood , Nazar Kazakov , William Salmon , Kiran Ostrolenk , Max Chou , Daniel Henrique Barboza , Alistair Francis Subject: [PULL 15/65] target/riscv: Add Zvbb ISA extension support Date: Fri, 8 Sep 2023 16:03:41 +1000 Message-ID: <20230908060431.1903919-16-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::1032; envelope-from=alistair23@gmail.com; helo=mail-pj1-x1032.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: 1694153239755100002 Content-Type: text/plain; charset="utf-8" From: Dickon Hood This commit adds support for the Zvbb vector-crypto extension, which consists of the following instructions: * vrol.[vv,vx] * vror.[vv,vx,vi] * vbrev8.v * vrev8.v * vandn.[vv,vx] * vbrev.v * vclz.v * vctz.v * vcpop.v * vwsll.[vv,vx,vi] Translation functions are defined in `target/riscv/insn_trans/trans_rvvk.c.inc` and helpers are defined in `target/riscv/vcrypto_helper.c`. Co-authored-by: Nazar Kazakov Co-authored-by: William Salmon Co-authored-by: Kiran Ostrolenk [max.chou@sifive.com: Fix imm mode of vror.vi] Signed-off-by: Nazar Kazakov Signed-off-by: William Salmon Signed-off-by: Kiran Ostrolenk Signed-off-by: Dickon Hood Signed-off-by: Max Chou Reviewed-by: Daniel Henrique Barboza [max.chou@sifive.com: Exposed x-zvbb property] Message-ID: <20230711165917.2629866-9-max.chou@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/cpu_cfg.h | 1 + target/riscv/helper.h | 62 +++++++++ target/riscv/insn32.decode | 20 +++ target/riscv/cpu.c | 12 ++ target/riscv/vcrypto_helper.c | 138 +++++++++++++++++++ target/riscv/insn_trans/trans_rvvk.c.inc | 164 +++++++++++++++++++++++ 6 files changed, 397 insertions(+) diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h index d25b36a512..0e31ebeed9 100644 --- a/target/riscv/cpu_cfg.h +++ b/target/riscv/cpu_cfg.h @@ -85,6 +85,7 @@ struct RISCVCPUConfig { bool ext_zve32f; bool ext_zve64f; bool ext_zve64d; + bool ext_zvbb; bool ext_zvbc; bool ext_zmmul; bool ext_zvfbfmin; diff --git a/target/riscv/helper.h b/target/riscv/helper.h index 6776777c4e..3db25ed2a2 100644 --- a/target/riscv/helper.h +++ b/target/riscv/helper.h @@ -1188,3 +1188,65 @@ DEF_HELPER_6(vclmul_vv, void, ptr, ptr, ptr, ptr, en= v, i32) DEF_HELPER_6(vclmul_vx, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vclmulh_vv, void, ptr, ptr, ptr, ptr, env, i32) DEF_HELPER_6(vclmulh_vx, void, ptr, ptr, tl, ptr, env, i32) + +DEF_HELPER_6(vror_vv_b, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vror_vv_h, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vror_vv_w, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vror_vv_d, void, ptr, ptr, ptr, ptr, env, i32) + +DEF_HELPER_6(vror_vx_b, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vror_vx_h, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vror_vx_w, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vror_vx_d, void, ptr, ptr, tl, ptr, env, i32) + +DEF_HELPER_6(vrol_vv_b, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vrol_vv_h, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vrol_vv_w, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vrol_vv_d, void, ptr, ptr, ptr, ptr, env, i32) + +DEF_HELPER_6(vrol_vx_b, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vrol_vx_h, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vrol_vx_w, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vrol_vx_d, void, ptr, ptr, tl, ptr, env, i32) + +DEF_HELPER_5(vrev8_v_b, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vrev8_v_h, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vrev8_v_w, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vrev8_v_d, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vbrev8_v_b, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vbrev8_v_h, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vbrev8_v_w, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vbrev8_v_d, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vbrev_v_b, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vbrev_v_h, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vbrev_v_w, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vbrev_v_d, void, ptr, ptr, ptr, env, i32) + +DEF_HELPER_5(vclz_v_b, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vclz_v_h, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vclz_v_w, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vclz_v_d, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vctz_v_b, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vctz_v_h, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vctz_v_w, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vctz_v_d, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vcpop_v_b, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vcpop_v_h, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vcpop_v_w, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vcpop_v_d, void, ptr, ptr, ptr, env, i32) + +DEF_HELPER_6(vwsll_vv_b, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vwsll_vv_h, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vwsll_vv_w, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vwsll_vx_b, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vwsll_vx_h, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vwsll_vx_w, void, ptr, ptr, tl, ptr, env, i32) + +DEF_HELPER_6(vandn_vv_b, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vandn_vv_h, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vandn_vv_w, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vandn_vv_d, void, ptr, ptr, ptr, ptr, env, i32) +DEF_HELPER_6(vandn_vx_b, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vandn_vx_h, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vandn_vx_w, void, ptr, ptr, tl, ptr, env, i32) +DEF_HELPER_6(vandn_vx_d, void, ptr, ptr, tl, ptr, env, i32) diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode index dd50d5a48c..b982a8325b 100644 --- a/target/riscv/insn32.decode +++ b/target/riscv/insn32.decode @@ -37,6 +37,7 @@ %imm_u 12:s20 !function=3Dex_shift_12 %imm_bs 30:2 !function=3Dex_shift_3 %imm_rnum 20:4 +%imm_z6 26:1 15:5 =20 # Argument sets: &empty @@ -82,6 +83,7 @@ @r_vm ...... vm:1 ..... ..... ... ..... ....... &rmrr %rs2 %rs1 %rd @r_vm_1 ...... . ..... ..... ... ..... ....... &rmrr vm=3D1 %rs2 %rs1 = %rd @r_vm_0 ...... . ..... ..... ... ..... ....... &rmrr vm=3D0 %rs2 %rs1 = %rd +@r2_zimm6 ..... . vm:1 ..... ..... ... ..... ....... &rmrr %rs2 rs1=3D%i= mm_z6 %rd @r2_zimm11 . zimm:11 ..... ... ..... ....... %rs1 %rd @r2_zimm10 .. zimm:10 ..... ... ..... ....... %rs1 %rd @r2_s ....... ..... ..... ... ..... ....... %rs2 %rs1 @@ -952,3 +954,21 @@ vclmul_vv 001100 . ..... ..... 010 ..... 1010111 @r_= vm vclmul_vx 001100 . ..... ..... 110 ..... 1010111 @r_vm vclmulh_vv 001101 . ..... ..... 010 ..... 1010111 @r_vm vclmulh_vx 001101 . ..... ..... 110 ..... 1010111 @r_vm + +# *** Zvbb vector crypto extension *** +vrol_vv 010101 . ..... ..... 000 ..... 1010111 @r_vm +vrol_vx 010101 . ..... ..... 100 ..... 1010111 @r_vm +vror_vv 010100 . ..... ..... 000 ..... 1010111 @r_vm +vror_vx 010100 . ..... ..... 100 ..... 1010111 @r_vm +vror_vi 01010. . ..... ..... 011 ..... 1010111 @r2_zimm6 +vbrev8_v 010010 . ..... 01000 010 ..... 1010111 @r2_vm +vrev8_v 010010 . ..... 01001 010 ..... 1010111 @r2_vm +vandn_vv 000001 . ..... ..... 000 ..... 1010111 @r_vm +vandn_vx 000001 . ..... ..... 100 ..... 1010111 @r_vm +vbrev_v 010010 . ..... 01010 010 ..... 1010111 @r2_vm +vclz_v 010010 . ..... 01100 010 ..... 1010111 @r2_vm +vctz_v 010010 . ..... 01101 010 ..... 1010111 @r2_vm +vcpop_v 010010 . ..... 01110 010 ..... 1010111 @r2_vm +vwsll_vv 110101 . ..... ..... 000 ..... 1010111 @r_vm +vwsll_vx 110101 . ..... ..... 100 ..... 1010111 @r_vm +vwsll_vi 110101 . ..... ..... 011 ..... 1010111 @r_vm diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index f74e0926c2..ccffbad4f5 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -120,6 +120,7 @@ static const struct isa_ext_data isa_edata_arr[] =3D { ISA_EXT_DATA_ENTRY(zksed, PRIV_VERSION_1_12_0, ext_zksed), ISA_EXT_DATA_ENTRY(zksh, PRIV_VERSION_1_12_0, ext_zksh), ISA_EXT_DATA_ENTRY(zkt, PRIV_VERSION_1_12_0, ext_zkt), + ISA_EXT_DATA_ENTRY(zvbb, PRIV_VERSION_1_12_0, ext_zvbb), ISA_EXT_DATA_ENTRY(zvbc, PRIV_VERSION_1_12_0, ext_zvbc), ISA_EXT_DATA_ENTRY(zve32f, PRIV_VERSION_1_10_0, ext_zve32f), ISA_EXT_DATA_ENTRY(zve64f, PRIV_VERSION_1_10_0, ext_zve64f), @@ -1272,6 +1273,16 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu= , Error **errp) return; } =20 + /* + * In principle Zve*x would also suffice here, were they supported + * in qemu + */ + if (cpu->cfg.ext_zvbb && !cpu->cfg.ext_zve32f) { + error_setg(errp, + "Vector crypto extensions require V or Zve* extensions"= ); + return; + } + if (cpu->cfg.ext_zvbc && !cpu->cfg.ext_zve64f) { error_setg(errp, "Zvbc extension requires V or Zve64{f,d} extensio= ns"); return; @@ -1860,6 +1871,7 @@ static Property riscv_cpu_extensions[] =3D { DEFINE_PROP_BOOL("x-zvfbfwma", RISCVCPU, cfg.ext_zvfbfwma, false), =20 /* Vector cryptography extensions */ + DEFINE_PROP_BOOL("x-zvbb", RISCVCPU, cfg.ext_zvbb, false), DEFINE_PROP_BOOL("x-zvbc", RISCVCPU, cfg.ext_zvbc, false), =20 DEFINE_PROP_END_OF_LIST(), diff --git a/target/riscv/vcrypto_helper.c b/target/riscv/vcrypto_helper.c index 8b7c63d499..11239b59d6 100644 --- a/target/riscv/vcrypto_helper.c +++ b/target/riscv/vcrypto_helper.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "qemu/host-utils.h" #include "qemu/bitops.h" +#include "qemu/bswap.h" #include "cpu.h" #include "exec/memop.h" #include "exec/exec-all.h" @@ -57,3 +58,140 @@ RVVCALL(OPIVV2, vclmulh_vv, OP_UUU_D, H8, H8, H8, clmul= h64) GEN_VEXT_VV(vclmulh_vv, 8) RVVCALL(OPIVX2, vclmulh_vx, OP_UUU_D, H8, H8, clmulh64) GEN_VEXT_VX(vclmulh_vx, 8) + +RVVCALL(OPIVV2, vror_vv_b, OP_UUU_B, H1, H1, H1, ror8) +RVVCALL(OPIVV2, vror_vv_h, OP_UUU_H, H2, H2, H2, ror16) +RVVCALL(OPIVV2, vror_vv_w, OP_UUU_W, H4, H4, H4, ror32) +RVVCALL(OPIVV2, vror_vv_d, OP_UUU_D, H8, H8, H8, ror64) +GEN_VEXT_VV(vror_vv_b, 1) +GEN_VEXT_VV(vror_vv_h, 2) +GEN_VEXT_VV(vror_vv_w, 4) +GEN_VEXT_VV(vror_vv_d, 8) + +RVVCALL(OPIVX2, vror_vx_b, OP_UUU_B, H1, H1, ror8) +RVVCALL(OPIVX2, vror_vx_h, OP_UUU_H, H2, H2, ror16) +RVVCALL(OPIVX2, vror_vx_w, OP_UUU_W, H4, H4, ror32) +RVVCALL(OPIVX2, vror_vx_d, OP_UUU_D, H8, H8, ror64) +GEN_VEXT_VX(vror_vx_b, 1) +GEN_VEXT_VX(vror_vx_h, 2) +GEN_VEXT_VX(vror_vx_w, 4) +GEN_VEXT_VX(vror_vx_d, 8) + +RVVCALL(OPIVV2, vrol_vv_b, OP_UUU_B, H1, H1, H1, rol8) +RVVCALL(OPIVV2, vrol_vv_h, OP_UUU_H, H2, H2, H2, rol16) +RVVCALL(OPIVV2, vrol_vv_w, OP_UUU_W, H4, H4, H4, rol32) +RVVCALL(OPIVV2, vrol_vv_d, OP_UUU_D, H8, H8, H8, rol64) +GEN_VEXT_VV(vrol_vv_b, 1) +GEN_VEXT_VV(vrol_vv_h, 2) +GEN_VEXT_VV(vrol_vv_w, 4) +GEN_VEXT_VV(vrol_vv_d, 8) + +RVVCALL(OPIVX2, vrol_vx_b, OP_UUU_B, H1, H1, rol8) +RVVCALL(OPIVX2, vrol_vx_h, OP_UUU_H, H2, H2, rol16) +RVVCALL(OPIVX2, vrol_vx_w, OP_UUU_W, H4, H4, rol32) +RVVCALL(OPIVX2, vrol_vx_d, OP_UUU_D, H8, H8, rol64) +GEN_VEXT_VX(vrol_vx_b, 1) +GEN_VEXT_VX(vrol_vx_h, 2) +GEN_VEXT_VX(vrol_vx_w, 4) +GEN_VEXT_VX(vrol_vx_d, 8) + +static uint64_t brev8(uint64_t val) +{ + val =3D ((val & 0x5555555555555555ull) << 1) | + ((val & 0xAAAAAAAAAAAAAAAAull) >> 1); + val =3D ((val & 0x3333333333333333ull) << 2) | + ((val & 0xCCCCCCCCCCCCCCCCull) >> 2); + val =3D ((val & 0x0F0F0F0F0F0F0F0Full) << 4) | + ((val & 0xF0F0F0F0F0F0F0F0ull) >> 4); + + return val; +} + +RVVCALL(OPIVV1, vbrev8_v_b, OP_UU_B, H1, H1, brev8) +RVVCALL(OPIVV1, vbrev8_v_h, OP_UU_H, H2, H2, brev8) +RVVCALL(OPIVV1, vbrev8_v_w, OP_UU_W, H4, H4, brev8) +RVVCALL(OPIVV1, vbrev8_v_d, OP_UU_D, H8, H8, brev8) +GEN_VEXT_V(vbrev8_v_b, 1) +GEN_VEXT_V(vbrev8_v_h, 2) +GEN_VEXT_V(vbrev8_v_w, 4) +GEN_VEXT_V(vbrev8_v_d, 8) + +#define DO_IDENTITY(a) (a) +RVVCALL(OPIVV1, vrev8_v_b, OP_UU_B, H1, H1, DO_IDENTITY) +RVVCALL(OPIVV1, vrev8_v_h, OP_UU_H, H2, H2, bswap16) +RVVCALL(OPIVV1, vrev8_v_w, OP_UU_W, H4, H4, bswap32) +RVVCALL(OPIVV1, vrev8_v_d, OP_UU_D, H8, H8, bswap64) +GEN_VEXT_V(vrev8_v_b, 1) +GEN_VEXT_V(vrev8_v_h, 2) +GEN_VEXT_V(vrev8_v_w, 4) +GEN_VEXT_V(vrev8_v_d, 8) + +#define DO_ANDN(a, b) ((a) & ~(b)) +RVVCALL(OPIVV2, vandn_vv_b, OP_UUU_B, H1, H1, H1, DO_ANDN) +RVVCALL(OPIVV2, vandn_vv_h, OP_UUU_H, H2, H2, H2, DO_ANDN) +RVVCALL(OPIVV2, vandn_vv_w, OP_UUU_W, H4, H4, H4, DO_ANDN) +RVVCALL(OPIVV2, vandn_vv_d, OP_UUU_D, H8, H8, H8, DO_ANDN) +GEN_VEXT_VV(vandn_vv_b, 1) +GEN_VEXT_VV(vandn_vv_h, 2) +GEN_VEXT_VV(vandn_vv_w, 4) +GEN_VEXT_VV(vandn_vv_d, 8) + +RVVCALL(OPIVX2, vandn_vx_b, OP_UUU_B, H1, H1, DO_ANDN) +RVVCALL(OPIVX2, vandn_vx_h, OP_UUU_H, H2, H2, DO_ANDN) +RVVCALL(OPIVX2, vandn_vx_w, OP_UUU_W, H4, H4, DO_ANDN) +RVVCALL(OPIVX2, vandn_vx_d, OP_UUU_D, H8, H8, DO_ANDN) +GEN_VEXT_VX(vandn_vx_b, 1) +GEN_VEXT_VX(vandn_vx_h, 2) +GEN_VEXT_VX(vandn_vx_w, 4) +GEN_VEXT_VX(vandn_vx_d, 8) + +RVVCALL(OPIVV1, vbrev_v_b, OP_UU_B, H1, H1, revbit8) +RVVCALL(OPIVV1, vbrev_v_h, OP_UU_H, H2, H2, revbit16) +RVVCALL(OPIVV1, vbrev_v_w, OP_UU_W, H4, H4, revbit32) +RVVCALL(OPIVV1, vbrev_v_d, OP_UU_D, H8, H8, revbit64) +GEN_VEXT_V(vbrev_v_b, 1) +GEN_VEXT_V(vbrev_v_h, 2) +GEN_VEXT_V(vbrev_v_w, 4) +GEN_VEXT_V(vbrev_v_d, 8) + +RVVCALL(OPIVV1, vclz_v_b, OP_UU_B, H1, H1, clz8) +RVVCALL(OPIVV1, vclz_v_h, OP_UU_H, H2, H2, clz16) +RVVCALL(OPIVV1, vclz_v_w, OP_UU_W, H4, H4, clz32) +RVVCALL(OPIVV1, vclz_v_d, OP_UU_D, H8, H8, clz64) +GEN_VEXT_V(vclz_v_b, 1) +GEN_VEXT_V(vclz_v_h, 2) +GEN_VEXT_V(vclz_v_w, 4) +GEN_VEXT_V(vclz_v_d, 8) + +RVVCALL(OPIVV1, vctz_v_b, OP_UU_B, H1, H1, ctz8) +RVVCALL(OPIVV1, vctz_v_h, OP_UU_H, H2, H2, ctz16) +RVVCALL(OPIVV1, vctz_v_w, OP_UU_W, H4, H4, ctz32) +RVVCALL(OPIVV1, vctz_v_d, OP_UU_D, H8, H8, ctz64) +GEN_VEXT_V(vctz_v_b, 1) +GEN_VEXT_V(vctz_v_h, 2) +GEN_VEXT_V(vctz_v_w, 4) +GEN_VEXT_V(vctz_v_d, 8) + +RVVCALL(OPIVV1, vcpop_v_b, OP_UU_B, H1, H1, ctpop8) +RVVCALL(OPIVV1, vcpop_v_h, OP_UU_H, H2, H2, ctpop16) +RVVCALL(OPIVV1, vcpop_v_w, OP_UU_W, H4, H4, ctpop32) +RVVCALL(OPIVV1, vcpop_v_d, OP_UU_D, H8, H8, ctpop64) +GEN_VEXT_V(vcpop_v_b, 1) +GEN_VEXT_V(vcpop_v_h, 2) +GEN_VEXT_V(vcpop_v_w, 4) +GEN_VEXT_V(vcpop_v_d, 8) + +#define DO_SLL(N, M) (N << (M & (sizeof(N) * 8 - 1))) +RVVCALL(OPIVV2, vwsll_vv_b, WOP_UUU_B, H2, H1, H1, DO_SLL) +RVVCALL(OPIVV2, vwsll_vv_h, WOP_UUU_H, H4, H2, H2, DO_SLL) +RVVCALL(OPIVV2, vwsll_vv_w, WOP_UUU_W, H8, H4, H4, DO_SLL) +GEN_VEXT_VV(vwsll_vv_b, 2) +GEN_VEXT_VV(vwsll_vv_h, 4) +GEN_VEXT_VV(vwsll_vv_w, 8) + +RVVCALL(OPIVX2, vwsll_vx_b, WOP_UUU_B, H2, H1, DO_SLL) +RVVCALL(OPIVX2, vwsll_vx_h, WOP_UUU_H, H4, H2, DO_SLL) +RVVCALL(OPIVX2, vwsll_vx_w, WOP_UUU_W, H8, H4, DO_SLL) +GEN_VEXT_VX(vwsll_vx_b, 2) +GEN_VEXT_VX(vwsll_vx_h, 4) +GEN_VEXT_VX(vwsll_vx_w, 8) diff --git a/target/riscv/insn_trans/trans_rvvk.c.inc b/target/riscv/insn_t= rans/trans_rvvk.c.inc index 552b08a2fd..0e4b337613 100644 --- a/target/riscv/insn_trans/trans_rvvk.c.inc +++ b/target/riscv/insn_trans/trans_rvvk.c.inc @@ -60,3 +60,167 @@ static bool vclmul_vx_check(DisasContext *s, arg_rmrr *= a) =20 GEN_VX_MASKED_TRANS(vclmul_vx, vclmul_vx_check) GEN_VX_MASKED_TRANS(vclmulh_vx, vclmul_vx_check) + +/* + * Zvbb + */ + +#define GEN_OPIVI_GVEC_TRANS_CHECK(NAME, IMM_MODE, OPIVX, SUF, CHECK) \ + static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ + { \ + if (CHECK(s, a)) { \ + static gen_helper_opivx *const fns[4] =3D { \ + gen_helper_##OPIVX##_b, \ + gen_helper_##OPIVX##_h, \ + gen_helper_##OPIVX##_w, \ + gen_helper_##OPIVX##_d, \ + }; \ + return do_opivi_gvec(s, a, tcg_gen_gvec_##SUF, fns[s->sew], \ + IMM_MODE); \ + } \ + return false; \ + } + +#define GEN_OPIVV_GVEC_TRANS_CHECK(NAME, SUF, CHECK) \ + static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ + { \ + if (CHECK(s, a)) { \ + static gen_helper_gvec_4_ptr *const fns[4] =3D { = \ + gen_helper_##NAME##_b, \ + gen_helper_##NAME##_h, \ + gen_helper_##NAME##_w, \ + gen_helper_##NAME##_d, \ + }; \ + return do_opivv_gvec(s, a, tcg_gen_gvec_##SUF, fns[s->sew]); \ + } \ + return false; \ + } + +#define GEN_OPIVX_GVEC_SHIFT_TRANS_CHECK(NAME, SUF, CHECK) \ + static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ + { \ + if (CHECK(s, a)) { \ + static gen_helper_opivx *const fns[4] =3D { \ + gen_helper_##NAME##_b, \ + gen_helper_##NAME##_h, \ + gen_helper_##NAME##_w, \ + gen_helper_##NAME##_d, \ + }; \ + return do_opivx_gvec_shift(s, a, tcg_gen_gvec_##SUF, \ + fns[s->sew]); \ + } \ + return false; \ + } + +static bool zvbb_vv_check(DisasContext *s, arg_rmrr *a) +{ + return opivv_check(s, a) && s->cfg_ptr->ext_zvbb =3D=3D true; +} + +static bool zvbb_vx_check(DisasContext *s, arg_rmrr *a) +{ + return opivx_check(s, a) && s->cfg_ptr->ext_zvbb =3D=3D true; +} + +/* vrol.v[vx] */ +GEN_OPIVV_GVEC_TRANS_CHECK(vrol_vv, rotlv, zvbb_vv_check) +GEN_OPIVX_GVEC_SHIFT_TRANS_CHECK(vrol_vx, rotls, zvbb_vx_check) + +/* vror.v[vxi] */ +GEN_OPIVV_GVEC_TRANS_CHECK(vror_vv, rotrv, zvbb_vv_check) +GEN_OPIVX_GVEC_SHIFT_TRANS_CHECK(vror_vx, rotrs, zvbb_vx_check) +GEN_OPIVI_GVEC_TRANS_CHECK(vror_vi, IMM_TRUNC_SEW, vror_vx, rotri, zvbb_vx= _check) + +#define GEN_OPIVX_GVEC_TRANS_CHECK(NAME, SUF, CHECK) \ + static bool trans_##NAME(DisasContext *s, arg_rmrr *a) \ + { \ + if (CHECK(s, a)) { \ + static gen_helper_opivx *const fns[4] =3D { = \ + gen_helper_##NAME##_b, \ + gen_helper_##NAME##_h, \ + gen_helper_##NAME##_w, \ + gen_helper_##NAME##_d, \ + }; \ + return do_opivx_gvec(s, a, tcg_gen_gvec_##SUF, fns[s->sew]); \ + } \ + return false; \ + } + +/* vandn.v[vx] */ +GEN_OPIVV_GVEC_TRANS_CHECK(vandn_vv, andc, zvbb_vv_check) +GEN_OPIVX_GVEC_TRANS_CHECK(vandn_vx, andcs, zvbb_vx_check) + +#define GEN_OPIV_TRANS(NAME, CHECK) = \ + static bool trans_##NAME(DisasContext *s, arg_rmr *a) = \ + { = \ + if (CHECK(s, a)) { = \ + uint32_t data =3D 0; = \ + static gen_helper_gvec_3_ptr *const fns[4] =3D { = \ + gen_helper_##NAME##_b, = \ + gen_helper_##NAME##_h, = \ + gen_helper_##NAME##_w, = \ + gen_helper_##NAME##_d, = \ + }; = \ + TCGLabel *over =3D gen_new_label(); = \ + tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); = \ + = \ + data =3D FIELD_DP32(data, VDATA, VM, a->vm); = \ + data =3D FIELD_DP32(data, VDATA, LMUL, s->lmul); = \ + data =3D FIELD_DP32(data, VDATA, VTA, s->vta); = \ + data =3D FIELD_DP32(data, VDATA, VTA_ALL_1S, s->cfg_vta_all_1s= ); \ + data =3D FIELD_DP32(data, VDATA, VMA, s->vma); = \ + tcg_gen_gvec_3_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, 0), = \ + vreg_ofs(s, a->rs2), cpu_env, = \ + s->cfg_ptr->vlen / 8, s->cfg_ptr->vlen / 8,= \ + data, fns[s->sew]); = \ + mark_vs_dirty(s); = \ + gen_set_label(over); = \ + return true; = \ + } = \ + return false; = \ + } + +static bool zvbb_opiv_check(DisasContext *s, arg_rmr *a) +{ + return s->cfg_ptr->ext_zvbb =3D=3D true && + require_rvv(s) && + vext_check_isa_ill(s) && + vext_check_ss(s, a->rd, a->rs2, a->vm); +} + +GEN_OPIV_TRANS(vbrev8_v, zvbb_opiv_check) +GEN_OPIV_TRANS(vrev8_v, zvbb_opiv_check) +GEN_OPIV_TRANS(vbrev_v, zvbb_opiv_check) +GEN_OPIV_TRANS(vclz_v, zvbb_opiv_check) +GEN_OPIV_TRANS(vctz_v, zvbb_opiv_check) +GEN_OPIV_TRANS(vcpop_v, zvbb_opiv_check) + +static bool vwsll_vv_check(DisasContext *s, arg_rmrr *a) +{ + return s->cfg_ptr->ext_zvbb && opivv_widen_check(s, a); +} + +static bool vwsll_vx_check(DisasContext *s, arg_rmrr *a) +{ + return s->cfg_ptr->ext_zvbb && opivx_widen_check(s, a); +} + +/* OPIVI without GVEC IR */ +#define GEN_OPIVI_WIDEN_TRANS(NAME, IMM_MODE, OPIVX, CHECK) = \ + static bool trans_##NAME(DisasContext *s, arg_rmrr *a) = \ + { = \ + if (CHECK(s, a)) { = \ + static gen_helper_opivx *const fns[3] =3D { = \ + gen_helper_##OPIVX##_b, = \ + gen_helper_##OPIVX##_h, = \ + gen_helper_##OPIVX##_w, = \ + }; = \ + return opivi_trans(a->rd, a->rs1, a->rs2, a->vm, fns[s->sew], = s, \ + IMM_MODE); = \ + } = \ + return false; = \ + } + +GEN_OPIVV_WIDEN_TRANS(vwsll_vv, vwsll_vv_check) +GEN_OPIVX_WIDEN_TRANS(vwsll_vx, vwsll_vx_check) +GEN_OPIVI_WIDEN_TRANS(vwsll_vi, IMM_ZX, vwsll_vx, vwsll_vx_check) --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153323; cv=none; d=zohomail.com; s=zohoarc; b=dfbFdITBB20UcLPY/7D7f0F/C60BoakNPAMPrJ32ki0Io6TIvikp3orE6F5xy2jcDzg2d2OLGIns7flKPW2Pji5s+ekgwdK6LJDHXt0xykd5Kh88tFFRVBYcrbsdfQTx5wn/CbkTqfQlRvQb8lwDhNrE8moOLuNcRw40UamDUT4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153323; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=T6Wnff6cN4ASLd2LCe5LGQprxWnrsyELRSlGnLzmNPw=; b=ZXlEGBkXJCf5ZE0n427AKk+z1WASJc9uR1IGYvyAKP40Mb3vSg/KNW6r0FDAtQEDQHJGSZ5AJbT4OVWV83yb4KHonPRXV7QOjcqn/1fEGKRgqi92pUBC3k0uzrh9Rv48NjU4BKCRDBDdWmnDlb2O9JOlPCCujmGgZ87CHTx+R4A= 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 1694153323975339.56374918966947; Thu, 7 Sep 2023 23:08:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUdU-0001LF-Vg; Fri, 08 Sep 2023 02:06:33 -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 1qeUd5-0000s0-19 for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:08 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUcz-0005hS-NU for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:05 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-68a41031768so1448870b3a.3 for ; Thu, 07 Sep 2023 23:06:00 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.05.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:05:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153158; x=1694757958; 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=T6Wnff6cN4ASLd2LCe5LGQprxWnrsyELRSlGnLzmNPw=; b=mlOfXTa+53G00Dtm3zoN0WFiUoqunSh6iRIK90wfr56auxdb5Zqm0+u1+FCmtPUKNf zkyAZUUzaXPz6pZEgakixwTZygUSQsnv9X8u0vIXbN49dgOL+qdoqrSP3SrUvmDYPrOc BgWrhbVAvDpUbCjCJ/2rfz6/nEJAiriNOnQg11P/JaWuvvOlPrEutDH/KIRRwDwM+nNk ffVh3YiHixcMGD91XZG0WWEYPYqAh15VHcG7pLwurxrtt4BNBO8iZ3sj86UUlS1XqVzp 3jd875/IJ4girtFB7lmuxl9Hq6fH3dfrLmr5gRRE17jCSVs+Dl5zBp5w08Y0DDbuGW2t ho1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153158; x=1694757958; 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=T6Wnff6cN4ASLd2LCe5LGQprxWnrsyELRSlGnLzmNPw=; b=GTPbb8U1Z6h2Vfwzg0EQuWSJArFcMzMhrMBTLvU8fEd8c76d46HldlU/5Vi9eETaz/ d5vyG2aYJD6ynB0cr0IWpfDA/RFDE8ishnS9g4Rb2iTGsqc7RG9/u2NPWxlTN7Xrwiwa KWJsnVEWJ09Tmydu3/4d135DQZqt6VLCM6XlDDNzrYQOQc2z1Owo1P09VtgHIhCp6pck gQ/yJawOlz6K7c8A52ylBU9+NDLiif/agHsJoI2ypc0P7e4nwPIFBkYzuIZedRj6QcAO rLffYuN2KuCfmJM795jWI7pO+6YyZwDVsU9lVLWoQJUVpfZtXQXBZHMmUNaeu/uwgPwz ToDQ== X-Gm-Message-State: AOJu0YygDjf4X45kIpMsXKtAFaU8YVdjptO6BrMSOblkvyevzgR2Yfb2 cXjuCR1XoYTlgvQHuQXB8VTtbnfRqLSxtSI5 X-Google-Smtp-Source: AGHT+IFgcePlhne6P5W1PV5PYpNckX8+vfz8MFqBl32uqKj4zrHCbqkSfTkIXCkN//5HVpd9PIko7Q== X-Received: by 2002:a05:6a20:cea2:b0:14c:76bd:10c1 with SMTP id if34-20020a056a20cea200b0014c76bd10c1mr1792043pzb.21.1694153157854; Thu, 07 Sep 2023 23:05:57 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Nazar Kazakov , Lawrence Hunter , William Salmon , Max Chou , Daniel Henrique Barboza , Alistair Francis Subject: [PULL 16/65] target/riscv: Add Zvkned ISA extension support Date: Fri, 8 Sep 2023 16:03:42 +1000 Message-ID: <20230908060431.1903919-17-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::430; envelope-from=alistair23@gmail.com; helo=mail-pf1-x430.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: 1694153325334100002 Content-Type: text/plain; charset="utf-8" From: Nazar Kazakov This commit adds support for the Zvkned vector-crypto extension, which consists of the following instructions: * vaesef.[vv,vs] * vaesdf.[vv,vs] * vaesdm.[vv,vs] * vaesz.vs * vaesem.[vv,vs] * vaeskf1.vi * vaeskf2.vi Translation functions are defined in `target/riscv/insn_trans/trans_rvvk.c.inc` and helpers are defined in `target/riscv/vcrypto_helper.c`. Co-authored-by: Lawrence Hunter Co-authored-by: William Salmon [max.chou@sifive.com: Replaced vstart checking by TCG op] Signed-off-by: Lawrence Hunter Signed-off-by: William Salmon Signed-off-by: Nazar Kazakov Signed-off-by: Max Chou Reviewed-by: Daniel Henrique Barboza [max.chou@sifive.com: Imported aes-round.h and exposed x-zvkned property] [max.chou@sifive.com: Fixed endian issues and replaced the vstart & vl egs checking by helper function] [max.chou@sifive.com: Replaced bswap32 calls in aes key expanding] Message-ID: <20230711165917.2629866-10-max.chou@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/cpu_cfg.h | 1 + target/riscv/helper.h | 14 ++ target/riscv/insn32.decode | 14 ++ target/riscv/cpu.c | 4 +- target/riscv/vcrypto_helper.c | 202 +++++++++++++++++++++++ target/riscv/insn_trans/trans_rvvk.c.inc | 147 +++++++++++++++++ 6 files changed, 381 insertions(+), 1 deletion(-) diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h index 0e31ebeed9..c7eafe27c0 100644 --- a/target/riscv/cpu_cfg.h +++ b/target/riscv/cpu_cfg.h @@ -87,6 +87,7 @@ struct RISCVCPUConfig { bool ext_zve64d; bool ext_zvbb; bool ext_zvbc; + bool ext_zvkned; bool ext_zmmul; bool ext_zvfbfmin; bool ext_zvfbfwma; diff --git a/target/riscv/helper.h b/target/riscv/helper.h index 3db25ed2a2..02e5dbe6ee 100644 --- a/target/riscv/helper.h +++ b/target/riscv/helper.h @@ -1250,3 +1250,17 @@ DEF_HELPER_6(vandn_vx_b, void, ptr, ptr, tl, ptr, en= v, i32) DEF_HELPER_6(vandn_vx_h, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vandn_vx_w, void, ptr, ptr, tl, ptr, env, i32) DEF_HELPER_6(vandn_vx_d, void, ptr, ptr, tl, ptr, env, i32) + +DEF_HELPER_2(egs_check, void, i32, env) + +DEF_HELPER_4(vaesef_vv, void, ptr, ptr, env, i32) +DEF_HELPER_4(vaesef_vs, void, ptr, ptr, env, i32) +DEF_HELPER_4(vaesdf_vv, void, ptr, ptr, env, i32) +DEF_HELPER_4(vaesdf_vs, void, ptr, ptr, env, i32) +DEF_HELPER_4(vaesem_vv, void, ptr, ptr, env, i32) +DEF_HELPER_4(vaesem_vs, void, ptr, ptr, env, i32) +DEF_HELPER_4(vaesdm_vv, void, ptr, ptr, env, i32) +DEF_HELPER_4(vaesdm_vs, void, ptr, ptr, env, i32) +DEF_HELPER_4(vaesz_vs, void, ptr, ptr, env, i32) +DEF_HELPER_5(vaeskf1_vi, void, ptr, ptr, i32, env, i32) +DEF_HELPER_5(vaeskf2_vi, void, ptr, ptr, i32, env, i32) diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode index b982a8325b..4f3c50f10f 100644 --- a/target/riscv/insn32.decode +++ b/target/riscv/insn32.decode @@ -75,6 +75,7 @@ @r_rm ....... ..... ..... ... ..... ....... %rs2 %rs1 %rm %rd @r2_rm ....... ..... ..... ... ..... ....... %rs1 %rm %rd @r2 ....... ..... ..... ... ..... ....... &r2 %rs1 %rd +@r2_vm_1 ...... . ..... ..... ... ..... ....... &rmr vm=3D1 %rs2 %rd @r2_nfvm ... ... vm:1 ..... ..... ... ..... ....... &r2nfvm %nf %rs1 %rd @r2_vm ...... vm:1 ..... ..... ... ..... ....... &rmr %rs2 %rd @r1_vm ...... vm:1 ..... ..... ... ..... ....... %rd @@ -972,3 +973,16 @@ vcpop_v 010010 . ..... 01110 010 ..... 1010111 @r2= _vm vwsll_vv 110101 . ..... ..... 000 ..... 1010111 @r_vm vwsll_vx 110101 . ..... ..... 100 ..... 1010111 @r_vm vwsll_vi 110101 . ..... ..... 011 ..... 1010111 @r_vm + +# *** Zvkned vector crypto extension *** +vaesef_vv 101000 1 ..... 00011 010 ..... 1110111 @r2_vm_1 +vaesef_vs 101001 1 ..... 00011 010 ..... 1110111 @r2_vm_1 +vaesdf_vv 101000 1 ..... 00001 010 ..... 1110111 @r2_vm_1 +vaesdf_vs 101001 1 ..... 00001 010 ..... 1110111 @r2_vm_1 +vaesem_vv 101000 1 ..... 00010 010 ..... 1110111 @r2_vm_1 +vaesem_vs 101001 1 ..... 00010 010 ..... 1110111 @r2_vm_1 +vaesdm_vv 101000 1 ..... 00000 010 ..... 1110111 @r2_vm_1 +vaesdm_vs 101001 1 ..... 00000 010 ..... 1110111 @r2_vm_1 +vaesz_vs 101001 1 ..... 00111 010 ..... 1110111 @r2_vm_1 +vaeskf1_vi 100010 1 ..... ..... 010 ..... 1110111 @r_vm_1 +vaeskf2_vi 101010 1 ..... ..... 010 ..... 1110111 @r_vm_1 diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index ccffbad4f5..8e3ae4d7e0 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -129,6 +129,7 @@ static const struct isa_ext_data isa_edata_arr[] =3D { ISA_EXT_DATA_ENTRY(zvfbfwma, PRIV_VERSION_1_12_0, ext_zvfbfwma), ISA_EXT_DATA_ENTRY(zvfh, PRIV_VERSION_1_12_0, ext_zvfh), ISA_EXT_DATA_ENTRY(zvfhmin, PRIV_VERSION_1_12_0, ext_zvfhmin), + ISA_EXT_DATA_ENTRY(zvkned, PRIV_VERSION_1_12_0, ext_zvkned), ISA_EXT_DATA_ENTRY(zhinx, PRIV_VERSION_1_12_0, ext_zhinx), ISA_EXT_DATA_ENTRY(zhinxmin, PRIV_VERSION_1_12_0, ext_zhinxmin), ISA_EXT_DATA_ENTRY(smaia, PRIV_VERSION_1_12_0, ext_smaia), @@ -1277,7 +1278,7 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu,= Error **errp) * In principle Zve*x would also suffice here, were they supported * in qemu */ - if (cpu->cfg.ext_zvbb && !cpu->cfg.ext_zve32f) { + if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkned) && !cpu->cfg.ext_zve32f= ) { error_setg(errp, "Vector crypto extensions require V or Zve* extensions"= ); return; @@ -1873,6 +1874,7 @@ static Property riscv_cpu_extensions[] =3D { /* Vector cryptography extensions */ DEFINE_PROP_BOOL("x-zvbb", RISCVCPU, cfg.ext_zvbb, false), DEFINE_PROP_BOOL("x-zvbc", RISCVCPU, cfg.ext_zvbc, false), + DEFINE_PROP_BOOL("x-zvkned", RISCVCPU, cfg.ext_zvkned, false), =20 DEFINE_PROP_END_OF_LIST(), }; diff --git a/target/riscv/vcrypto_helper.c b/target/riscv/vcrypto_helper.c index 11239b59d6..cca78184e9 100644 --- a/target/riscv/vcrypto_helper.c +++ b/target/riscv/vcrypto_helper.c @@ -22,6 +22,8 @@ #include "qemu/bitops.h" #include "qemu/bswap.h" #include "cpu.h" +#include "crypto/aes.h" +#include "crypto/aes-round.h" #include "exec/memop.h" #include "exec/exec-all.h" #include "exec/helper-proto.h" @@ -195,3 +197,203 @@ RVVCALL(OPIVX2, vwsll_vx_w, WOP_UUU_W, H8, H4, DO_SLL) GEN_VEXT_VX(vwsll_vx_b, 2) GEN_VEXT_VX(vwsll_vx_h, 4) GEN_VEXT_VX(vwsll_vx_w, 8) + +void HELPER(egs_check)(uint32_t egs, CPURISCVState *env) +{ + uint32_t vl =3D env->vl; + uint32_t vstart =3D env->vstart; + + if (vl % egs !=3D 0 || vstart % egs !=3D 0) { + riscv_raise_exception(env, RISCV_EXCP_ILLEGAL_INST, GETPC()); + } +} + +static inline void xor_round_key(AESState *round_state, AESState *round_ke= y) +{ + round_state->v =3D round_state->v ^ round_key->v; +} + +#define GEN_ZVKNED_HELPER_VV(NAME, ...) \ + void HELPER(NAME)(void *vd, void *vs2, CPURISCVState *env, \ + uint32_t desc) \ + { \ + uint32_t vl =3D env->vl; = \ + uint32_t total_elems =3D vext_get_total_elems(env, desc, 4); = \ + uint32_t vta =3D vext_vta(desc); = \ + \ + for (uint32_t i =3D env->vstart / 4; i < env->vl / 4; i++) { = \ + AESState round_key; \ + round_key.d[0] =3D *((uint64_t *)vs2 + H8(i * 2 + 0)); = \ + round_key.d[1] =3D *((uint64_t *)vs2 + H8(i * 2 + 1)); = \ + AESState round_state; \ + round_state.d[0] =3D *((uint64_t *)vd + H8(i * 2 + 0)); = \ + round_state.d[1] =3D *((uint64_t *)vd + H8(i * 2 + 1)); = \ + __VA_ARGS__; \ + *((uint64_t *)vd + H8(i * 2 + 0)) =3D round_state.d[0]; = \ + *((uint64_t *)vd + H8(i * 2 + 1)) =3D round_state.d[1]; = \ + } \ + env->vstart =3D 0; = \ + /* set tail elements to 1s */ \ + vext_set_elems_1s(vd, vta, vl * 4, total_elems * 4); \ + } + +#define GEN_ZVKNED_HELPER_VS(NAME, ...) \ + void HELPER(NAME)(void *vd, void *vs2, CPURISCVState *env, \ + uint32_t desc) \ + { \ + uint32_t vl =3D env->vl; = \ + uint32_t total_elems =3D vext_get_total_elems(env, desc, 4); = \ + uint32_t vta =3D vext_vta(desc); = \ + \ + for (uint32_t i =3D env->vstart / 4; i < env->vl / 4; i++) { = \ + AESState round_key; \ + round_key.d[0] =3D *((uint64_t *)vs2 + H8(0)); = \ + round_key.d[1] =3D *((uint64_t *)vs2 + H8(1)); = \ + AESState round_state; \ + round_state.d[0] =3D *((uint64_t *)vd + H8(i * 2 + 0)); = \ + round_state.d[1] =3D *((uint64_t *)vd + H8(i * 2 + 1)); = \ + __VA_ARGS__; \ + *((uint64_t *)vd + H8(i * 2 + 0)) =3D round_state.d[0]; = \ + *((uint64_t *)vd + H8(i * 2 + 1)) =3D round_state.d[1]; = \ + } \ + env->vstart =3D 0; = \ + /* set tail elements to 1s */ \ + vext_set_elems_1s(vd, vta, vl * 4, total_elems * 4); \ + } + +GEN_ZVKNED_HELPER_VV(vaesef_vv, aesenc_SB_SR_AK(&round_state, + &round_state, + &round_key, + false);) +GEN_ZVKNED_HELPER_VS(vaesef_vs, aesenc_SB_SR_AK(&round_state, + &round_state, + &round_key, + false);) +GEN_ZVKNED_HELPER_VV(vaesdf_vv, aesdec_ISB_ISR_AK(&round_state, + &round_state, + &round_key, + false);) +GEN_ZVKNED_HELPER_VS(vaesdf_vs, aesdec_ISB_ISR_AK(&round_state, + &round_state, + &round_key, + false);) +GEN_ZVKNED_HELPER_VV(vaesem_vv, aesenc_SB_SR_MC_AK(&round_state, + &round_state, + &round_key, + false);) +GEN_ZVKNED_HELPER_VS(vaesem_vs, aesenc_SB_SR_MC_AK(&round_state, + &round_state, + &round_key, + false);) +GEN_ZVKNED_HELPER_VV(vaesdm_vv, aesdec_ISB_ISR_AK_IMC(&round_state, + &round_state, + &round_key, + false);) +GEN_ZVKNED_HELPER_VS(vaesdm_vs, aesdec_ISB_ISR_AK_IMC(&round_state, + &round_state, + &round_key, + false);) +GEN_ZVKNED_HELPER_VS(vaesz_vs, xor_round_key(&round_state, &round_key);) + +void HELPER(vaeskf1_vi)(void *vd_vptr, void *vs2_vptr, uint32_t uimm, + CPURISCVState *env, uint32_t desc) +{ + uint32_t *vd =3D vd_vptr; + uint32_t *vs2 =3D vs2_vptr; + uint32_t vl =3D env->vl; + uint32_t total_elems =3D vext_get_total_elems(env, desc, 4); + uint32_t vta =3D vext_vta(desc); + + uimm &=3D 0b1111; + if (uimm > 10 || uimm =3D=3D 0) { + uimm ^=3D 0b1000; + } + + for (uint32_t i =3D env->vstart / 4; i < env->vl / 4; i++) { + uint32_t rk[8], tmp; + static const uint32_t rcon[] =3D { + 0x00000001, 0x00000002, 0x00000004, 0x00000008, 0x00000010, + 0x00000020, 0x00000040, 0x00000080, 0x0000001B, 0x00000036, + }; + + rk[0] =3D vs2[i * 4 + H4(0)]; + rk[1] =3D vs2[i * 4 + H4(1)]; + rk[2] =3D vs2[i * 4 + H4(2)]; + rk[3] =3D vs2[i * 4 + H4(3)]; + tmp =3D ror32(rk[3], 8); + + rk[4] =3D rk[0] ^ (((uint32_t)AES_sbox[(tmp >> 24) & 0xff] << 24) | + ((uint32_t)AES_sbox[(tmp >> 16) & 0xff] << 16) | + ((uint32_t)AES_sbox[(tmp >> 8) & 0xff] << 8) | + ((uint32_t)AES_sbox[(tmp >> 0) & 0xff] << 0)) + ^ rcon[uimm - 1]; + rk[5] =3D rk[1] ^ rk[4]; + rk[6] =3D rk[2] ^ rk[5]; + rk[7] =3D rk[3] ^ rk[6]; + + vd[i * 4 + H4(0)] =3D rk[4]; + vd[i * 4 + H4(1)] =3D rk[5]; + vd[i * 4 + H4(2)] =3D rk[6]; + vd[i * 4 + H4(3)] =3D rk[7]; + } + env->vstart =3D 0; + /* set tail elements to 1s */ + vext_set_elems_1s(vd, vta, vl * 4, total_elems * 4); +} + +void HELPER(vaeskf2_vi)(void *vd_vptr, void *vs2_vptr, uint32_t uimm, + CPURISCVState *env, uint32_t desc) +{ + uint32_t *vd =3D vd_vptr; + uint32_t *vs2 =3D vs2_vptr; + uint32_t vl =3D env->vl; + uint32_t total_elems =3D vext_get_total_elems(env, desc, 4); + uint32_t vta =3D vext_vta(desc); + + uimm &=3D 0b1111; + if (uimm > 14 || uimm < 2) { + uimm ^=3D 0b1000; + } + + for (uint32_t i =3D env->vstart / 4; i < env->vl / 4; i++) { + uint32_t rk[12], tmp; + static const uint32_t rcon[] =3D { + 0x00000001, 0x00000002, 0x00000004, 0x00000008, 0x00000010, + 0x00000020, 0x00000040, 0x00000080, 0x0000001B, 0x00000036, + }; + + rk[0] =3D vd[i * 4 + H4(0)]; + rk[1] =3D vd[i * 4 + H4(1)]; + rk[2] =3D vd[i * 4 + H4(2)]; + rk[3] =3D vd[i * 4 + H4(3)]; + rk[4] =3D vs2[i * 4 + H4(0)]; + rk[5] =3D vs2[i * 4 + H4(1)]; + rk[6] =3D vs2[i * 4 + H4(2)]; + rk[7] =3D vs2[i * 4 + H4(3)]; + + if (uimm % 2 =3D=3D 0) { + tmp =3D ror32(rk[7], 8); + rk[8] =3D rk[0] ^ (((uint32_t)AES_sbox[(tmp >> 24) & 0xff] << = 24) | + ((uint32_t)AES_sbox[(tmp >> 16) & 0xff] << 16= ) | + ((uint32_t)AES_sbox[(tmp >> 8) & 0xff] << 8) | + ((uint32_t)AES_sbox[(tmp >> 0) & 0xff] << 0)) + ^ rcon[(uimm - 1) / 2]; + } else { + rk[8] =3D rk[0] ^ (((uint32_t)AES_sbox[(rk[7] >> 24) & 0xff] <= < 24) | + ((uint32_t)AES_sbox[(rk[7] >> 16) & 0xff] << = 16) | + ((uint32_t)AES_sbox[(rk[7] >> 8) & 0xff] << 8= ) | + ((uint32_t)AES_sbox[(rk[7] >> 0) & 0xff] << 0= )); + } + rk[9] =3D rk[1] ^ rk[8]; + rk[10] =3D rk[2] ^ rk[9]; + rk[11] =3D rk[3] ^ rk[10]; + + vd[i * 4 + H4(0)] =3D rk[8]; + vd[i * 4 + H4(1)] =3D rk[9]; + vd[i * 4 + H4(2)] =3D rk[10]; + vd[i * 4 + H4(3)] =3D rk[11]; + } + env->vstart =3D 0; + /* set tail elements to 1s */ + vext_set_elems_1s(vd, vta, vl * 4, total_elems * 4); +} diff --git a/target/riscv/insn_trans/trans_rvvk.c.inc b/target/riscv/insn_t= rans/trans_rvvk.c.inc index 0e4b337613..817353f4d3 100644 --- a/target/riscv/insn_trans/trans_rvvk.c.inc +++ b/target/riscv/insn_trans/trans_rvvk.c.inc @@ -224,3 +224,150 @@ static bool vwsll_vx_check(DisasContext *s, arg_rmrr = *a) GEN_OPIVV_WIDEN_TRANS(vwsll_vv, vwsll_vv_check) GEN_OPIVX_WIDEN_TRANS(vwsll_vx, vwsll_vx_check) GEN_OPIVI_WIDEN_TRANS(vwsll_vi, IMM_ZX, vwsll_vx, vwsll_vx_check) + +/* + * Zvkned + */ + +#define ZVKNED_EGS 4 + +#define GEN_V_UNMASKED_TRANS(NAME, CHECK, EGS) = \ + static bool trans_##NAME(DisasContext *s, arg_##NAME *a) = \ + { = \ + if (CHECK(s, a)) { = \ + TCGv_ptr rd_v, rs2_v; = \ + TCGv_i32 desc, egs; = \ + uint32_t data =3D 0; = \ + TCGLabel *over =3D gen_new_label(); = \ + = \ + if (!s->vstart_eq_zero || !s->vl_eq_vlmax) { = \ + /* save opcode for unwinding in case we throw an exception= */ \ + decode_save_opc(s); = \ + egs =3D tcg_constant_i32(EGS); = \ + gen_helper_egs_check(egs, cpu_env); = \ + tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);= \ + } = \ + = \ + data =3D FIELD_DP32(data, VDATA, VM, a->vm); = \ + data =3D FIELD_DP32(data, VDATA, LMUL, s->lmul); = \ + data =3D FIELD_DP32(data, VDATA, VTA, s->vta); = \ + data =3D FIELD_DP32(data, VDATA, VTA_ALL_1S, s->cfg_vta_all_1s= ); \ + data =3D FIELD_DP32(data, VDATA, VMA, s->vma); = \ + rd_v =3D tcg_temp_new_ptr(); = \ + rs2_v =3D tcg_temp_new_ptr(); = \ + desc =3D tcg_constant_i32( = \ + simd_desc(s->cfg_ptr->vlen / 8, s->cfg_ptr->vlen / 8, data= )); \ + tcg_gen_addi_ptr(rd_v, cpu_env, vreg_ofs(s, a->rd)); = \ + tcg_gen_addi_ptr(rs2_v, cpu_env, vreg_ofs(s, a->rs2)); = \ + gen_helper_##NAME(rd_v, rs2_v, cpu_env, desc); = \ + mark_vs_dirty(s); = \ + gen_set_label(over); = \ + return true; = \ + } = \ + return false; = \ + } + +static bool vaes_check_vv(DisasContext *s, arg_rmr *a) +{ + int egw_bytes =3D ZVKNED_EGS << s->sew; + return s->cfg_ptr->ext_zvkned =3D=3D true && + require_rvv(s) && + vext_check_isa_ill(s) && + MAXSZ(s) >=3D egw_bytes && + require_align(a->rd, s->lmul) && + require_align(a->rs2, s->lmul) && + s->sew =3D=3D MO_32; +} + +static bool vaes_check_overlap(DisasContext *s, int vd, int vs2) +{ + int8_t op_size =3D s->lmul <=3D 0 ? 1 : 1 << s->lmul; + return !is_overlapped(vd, op_size, vs2, 1); +} + +static bool vaes_check_vs(DisasContext *s, arg_rmr *a) +{ + int egw_bytes =3D ZVKNED_EGS << s->sew; + return vaes_check_overlap(s, a->rd, a->rs2) && + MAXSZ(s) >=3D egw_bytes && + s->cfg_ptr->ext_zvkned =3D=3D true && + require_rvv(s) && + vext_check_isa_ill(s) && + require_align(a->rd, s->lmul) && + s->sew =3D=3D MO_32; +} + +GEN_V_UNMASKED_TRANS(vaesef_vv, vaes_check_vv, ZVKNED_EGS) +GEN_V_UNMASKED_TRANS(vaesef_vs, vaes_check_vs, ZVKNED_EGS) +GEN_V_UNMASKED_TRANS(vaesdf_vv, vaes_check_vv, ZVKNED_EGS) +GEN_V_UNMASKED_TRANS(vaesdf_vs, vaes_check_vs, ZVKNED_EGS) +GEN_V_UNMASKED_TRANS(vaesdm_vv, vaes_check_vv, ZVKNED_EGS) +GEN_V_UNMASKED_TRANS(vaesdm_vs, vaes_check_vs, ZVKNED_EGS) +GEN_V_UNMASKED_TRANS(vaesz_vs, vaes_check_vs, ZVKNED_EGS) +GEN_V_UNMASKED_TRANS(vaesem_vv, vaes_check_vv, ZVKNED_EGS) +GEN_V_UNMASKED_TRANS(vaesem_vs, vaes_check_vs, ZVKNED_EGS) + +#define GEN_VI_UNMASKED_TRANS(NAME, CHECK, EGS) = \ + static bool trans_##NAME(DisasContext *s, arg_##NAME *a) = \ + { = \ + if (CHECK(s, a)) { = \ + TCGv_ptr rd_v, rs2_v; = \ + TCGv_i32 uimm_v, desc, egs; = \ + uint32_t data =3D 0; = \ + TCGLabel *over =3D gen_new_label(); = \ + = \ + if (!s->vstart_eq_zero || !s->vl_eq_vlmax) { = \ + /* save opcode for unwinding in case we throw an exception= */ \ + decode_save_opc(s); = \ + egs =3D tcg_constant_i32(EGS); = \ + gen_helper_egs_check(egs, cpu_env); = \ + tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);= \ + } = \ + = \ + data =3D FIELD_DP32(data, VDATA, VM, a->vm); = \ + data =3D FIELD_DP32(data, VDATA, LMUL, s->lmul); = \ + data =3D FIELD_DP32(data, VDATA, VTA, s->vta); = \ + data =3D FIELD_DP32(data, VDATA, VTA_ALL_1S, s->cfg_vta_all_1s= ); \ + data =3D FIELD_DP32(data, VDATA, VMA, s->vma); = \ + = \ + rd_v =3D tcg_temp_new_ptr(); = \ + rs2_v =3D tcg_temp_new_ptr(); = \ + uimm_v =3D tcg_constant_i32(a->rs1); = \ + desc =3D tcg_constant_i32( = \ + simd_desc(s->cfg_ptr->vlen / 8, s->cfg_ptr->vlen / 8, data= )); \ + tcg_gen_addi_ptr(rd_v, cpu_env, vreg_ofs(s, a->rd)); = \ + tcg_gen_addi_ptr(rs2_v, cpu_env, vreg_ofs(s, a->rs2)); = \ + gen_helper_##NAME(rd_v, rs2_v, uimm_v, cpu_env, desc); = \ + mark_vs_dirty(s); = \ + gen_set_label(over); = \ + return true; = \ + } = \ + return false; = \ + } + +static bool vaeskf1_check(DisasContext *s, arg_vaeskf1_vi *a) +{ + int egw_bytes =3D ZVKNED_EGS << s->sew; + return s->cfg_ptr->ext_zvkned =3D=3D true && + require_rvv(s) && + vext_check_isa_ill(s) && + MAXSZ(s) >=3D egw_bytes && + s->sew =3D=3D MO_32 && + require_align(a->rd, s->lmul) && + require_align(a->rs2, s->lmul); +} + +static bool vaeskf2_check(DisasContext *s, arg_vaeskf2_vi *a) +{ + int egw_bytes =3D ZVKNED_EGS << s->sew; + return s->cfg_ptr->ext_zvkned =3D=3D true && + require_rvv(s) && + vext_check_isa_ill(s) && + MAXSZ(s) >=3D egw_bytes && + s->sew =3D=3D MO_32 && + require_align(a->rd, s->lmul) && + require_align(a->rs2, s->lmul); +} + +GEN_VI_UNMASKED_TRANS(vaeskf1_vi, vaeskf1_check, ZVKNED_EGS) +GEN_VI_UNMASKED_TRANS(vaeskf2_vi, vaeskf2_check, ZVKNED_EGS) --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153483; cv=none; d=zohomail.com; s=zohoarc; b=A4R9TSYVKnfHAoVEIDVZz/zeV7znPmNfx/dRQO840SQ4Yd98GIjP7d7urtkiJ8hkA+0WB/rg3E7SkIqBcdXmh8S9HTwFFS59WzDV4Tj+PPL3pU6JY3r8V9NTl/Tbie/g0Bs9xzWm3QxjWNE9KE+9rJgme9YtLEIpBF+2IzyaeiY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153483; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mTs5EAXQCNv7xKSmVs3cJPCQuWtkfKVB1HbSg6LBKOk=; b=h5DSZ7caM3J4l7nuU4CkXeyGLDMqCuQT6Fgn7P/7hSFkGE6LjlnyEOOSxLNrKerV+dXMM/Rs9x1OgURHvqATEdpgJT/rSkDuKQgnBIWX5sN6tF4Q4ep39NnQmlDuw3PWC7fXGxL2MuI/WIOTp9pAIExRKFLtg6ecdbZ/SPONhWA= 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 1694153483793156.34021021641945; Thu, 7 Sep 2023 23:11:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUdW-0001bC-Qy; Fri, 08 Sep 2023 02:06:34 -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 1qeUd6-0000sF-RW for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:09 -0400 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 1qeUd2-0005hn-Qt for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:07 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1c364fb8a4cso15565725ad.1 for ; Thu, 07 Sep 2023 23:06:03 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.05.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:06:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153162; x=1694757962; 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=mTs5EAXQCNv7xKSmVs3cJPCQuWtkfKVB1HbSg6LBKOk=; b=MLiJwFAUuBWokzQLb6vOms4X06e/u76gn/h4bvjXSi2UdJcqtXvTctmvHtswbv5FR2 +1uw4KcpwyYQMc8l91RQjBDtOv4IwVIKR4e7+9+9w8fj9PY/MdvA76L12LC4P5rPz3J6 LkrchMlV1JGO5QGT3EU+PEEEmmw95NH0eqiwleUjzOhZSeQJR9J1YpKf5FVRnTOr5ZN9 wZjCX2cI2kXdIDfKlvdc+oNkF22b/+BOpw0zKhnbz9s+K90UuB9CCWhjt2QCLxgCW/yN xTC+EejQbJGleL05llOuM0cLl5aGRS4QHEu5M7B63FL3ZBU4/TLM9paZIWSbgXeNSP9/ uQYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153162; x=1694757962; 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=mTs5EAXQCNv7xKSmVs3cJPCQuWtkfKVB1HbSg6LBKOk=; b=g+2lTU40We+iL1fskxA3Et/Z9nJXfT9NvnMWCZoeO7jB+iOXiq1kSK/QHug328Tdn2 nJw2h5dXLG8muu4qgJEEn+wkT+mtxuGeje5okFxhl4OHaAoZCQvqTOvyBfeW5W4MTW7z muxjmd/2eoWpoyVTx30wusJNtLecYgTaWRjKaSPstQOD/35gW+pmf+oMf40VT2bgBaUM O2iFfdDqupN9HxFj04h002rMpKLjmQW3Z5rmPhKccQWqd/KnwtF+3O/x0Rx5AWdq8J5k ynwMzpFzGhBMyNtEOOGnpjqk1+eDwvnCJKBZTAIaW22dbiZ37yzfw8KP5n0t7mKUUKxQ CqaQ== X-Gm-Message-State: AOJu0YzZQG9zeOGPfuk58FUDK4H+GYmv6z/5Nx5gNWY2Zx1PVOI6JEEe lBzoz+CenRujTMjab/duaGIB7QHnmDLBFaLN X-Google-Smtp-Source: AGHT+IFsQTxjShZ0v7ycK61AdPLEHwOSV1t79FVC9J82FIOjF2vl6j2sjrrT92aotH/OeMTZJkTsRg== X-Received: by 2002:a17:903:2605:b0:1bc:2d43:c741 with SMTP id jd5-20020a170903260500b001bc2d43c741mr1608767plb.66.1694153162119; Thu, 07 Sep 2023 23:06:02 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Kiran Ostrolenk , Nazar Kazakov , Lawrence Hunter , Max Chou , Daniel Henrique Barboza , Alistair Francis Subject: [PULL 17/65] target/riscv: Add Zvknh ISA extension support Date: Fri, 8 Sep 2023 16:03:43 +1000 Message-ID: <20230908060431.1903919-18-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::62f; envelope-from=alistair23@gmail.com; helo=mail-pl1-x62f.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: 1694153485297100015 Content-Type: text/plain; charset="utf-8" From: Kiran Ostrolenk This commit adds support for the Zvknh vector-crypto extension, which consists of the following instructions: * vsha2ms.vv * vsha2c[hl].vv Translation functions are defined in `target/riscv/insn_trans/trans_rvvk.c.inc` and helpers are defined in `target/riscv/vcrypto_helper.c`. Co-authored-by: Nazar Kazakov Co-authored-by: Lawrence Hunter [max.chou@sifive.com: Replaced vstart checking by TCG op] Signed-off-by: Nazar Kazakov Signed-off-by: Lawrence Hunter Signed-off-by: Kiran Ostrolenk Signed-off-by: Max Chou Reviewed-by: Daniel Henrique Barboza [max.chou@sifive.com: Exposed x-zvknha & x-zvknhb properties] [max.chou@sifive.com: Replaced SEW selection to happened during translation] Message-ID: <20230711165917.2629866-11-max.chou@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/cpu_cfg.h | 2 + target/riscv/helper.h | 6 + target/riscv/insn32.decode | 5 + target/riscv/cpu.c | 13 +- target/riscv/vcrypto_helper.c | 238 +++++++++++++++++++++++ target/riscv/insn_trans/trans_rvvk.c.inc | 129 ++++++++++++ 6 files changed, 390 insertions(+), 3 deletions(-) diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h index c7eafe27c0..800b8783c1 100644 --- a/target/riscv/cpu_cfg.h +++ b/target/riscv/cpu_cfg.h @@ -88,6 +88,8 @@ struct RISCVCPUConfig { bool ext_zvbb; bool ext_zvbc; bool ext_zvkned; + bool ext_zvknha; + bool ext_zvknhb; bool ext_zmmul; bool ext_zvfbfmin; bool ext_zvfbfwma; diff --git a/target/riscv/helper.h b/target/riscv/helper.h index 02e5dbe6ee..34329b52fe 100644 --- a/target/riscv/helper.h +++ b/target/riscv/helper.h @@ -1264,3 +1264,9 @@ DEF_HELPER_4(vaesdm_vs, void, ptr, ptr, env, i32) DEF_HELPER_4(vaesz_vs, void, ptr, ptr, env, i32) DEF_HELPER_5(vaeskf1_vi, void, ptr, ptr, i32, env, i32) DEF_HELPER_5(vaeskf2_vi, void, ptr, ptr, i32, env, i32) + +DEF_HELPER_5(vsha2ms_vv, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vsha2ch32_vv, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vsha2ch64_vv, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vsha2cl32_vv, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vsha2cl64_vv, void, ptr, ptr, ptr, env, i32) diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode index 4f3c50f10f..e2b83186dc 100644 --- a/target/riscv/insn32.decode +++ b/target/riscv/insn32.decode @@ -986,3 +986,8 @@ vaesdm_vs 101001 1 ..... 00000 010 ..... 1110111 @r2_= vm_1 vaesz_vs 101001 1 ..... 00111 010 ..... 1110111 @r2_vm_1 vaeskf1_vi 100010 1 ..... ..... 010 ..... 1110111 @r_vm_1 vaeskf2_vi 101010 1 ..... ..... 010 ..... 1110111 @r_vm_1 + +# *** Zvknh vector crypto extension *** +vsha2ms_vv 101101 1 ..... ..... 010 ..... 1110111 @r_vm_1 +vsha2ch_vv 101110 1 ..... ..... 010 ..... 1110111 @r_vm_1 +vsha2cl_vv 101111 1 ..... ..... 010 ..... 1110111 @r_vm_1 diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 8e3ae4d7e0..f103f536fd 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -130,6 +130,8 @@ static const struct isa_ext_data isa_edata_arr[] =3D { ISA_EXT_DATA_ENTRY(zvfh, PRIV_VERSION_1_12_0, ext_zvfh), ISA_EXT_DATA_ENTRY(zvfhmin, PRIV_VERSION_1_12_0, ext_zvfhmin), ISA_EXT_DATA_ENTRY(zvkned, PRIV_VERSION_1_12_0, ext_zvkned), + ISA_EXT_DATA_ENTRY(zvknha, PRIV_VERSION_1_12_0, ext_zvknha), + ISA_EXT_DATA_ENTRY(zvknhb, PRIV_VERSION_1_12_0, ext_zvknhb), ISA_EXT_DATA_ENTRY(zhinx, PRIV_VERSION_1_12_0, ext_zhinx), ISA_EXT_DATA_ENTRY(zhinxmin, PRIV_VERSION_1_12_0, ext_zhinxmin), ISA_EXT_DATA_ENTRY(smaia, PRIV_VERSION_1_12_0, ext_smaia), @@ -1278,14 +1280,17 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cp= u, Error **errp) * In principle Zve*x would also suffice here, were they supported * in qemu */ - if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkned) && !cpu->cfg.ext_zve32f= ) { + if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkned || cpu->cfg.ext_zvknha) = && + !cpu->cfg.ext_zve32f) { error_setg(errp, "Vector crypto extensions require V or Zve* extensions"= ); return; } =20 - if (cpu->cfg.ext_zvbc && !cpu->cfg.ext_zve64f) { - error_setg(errp, "Zvbc extension requires V or Zve64{f,d} extensio= ns"); + if ((cpu->cfg.ext_zvbc || cpu->cfg.ext_zvknhb) && !cpu->cfg.ext_zve64f= ) { + error_setg( + errp, + "Zvbc and Zvknhb extensions require V or Zve64{f,d} extensions= "); return; } =20 @@ -1875,6 +1880,8 @@ static Property riscv_cpu_extensions[] =3D { DEFINE_PROP_BOOL("x-zvbb", RISCVCPU, cfg.ext_zvbb, false), DEFINE_PROP_BOOL("x-zvbc", RISCVCPU, cfg.ext_zvbc, false), DEFINE_PROP_BOOL("x-zvkned", RISCVCPU, cfg.ext_zvkned, false), + DEFINE_PROP_BOOL("x-zvknha", RISCVCPU, cfg.ext_zvknha, false), + DEFINE_PROP_BOOL("x-zvknhb", RISCVCPU, cfg.ext_zvknhb, false), =20 DEFINE_PROP_END_OF_LIST(), }; diff --git a/target/riscv/vcrypto_helper.c b/target/riscv/vcrypto_helper.c index cca78184e9..2f2099b6fb 100644 --- a/target/riscv/vcrypto_helper.c +++ b/target/riscv/vcrypto_helper.c @@ -397,3 +397,241 @@ void HELPER(vaeskf2_vi)(void *vd_vptr, void *vs2_vptr= , uint32_t uimm, /* set tail elements to 1s */ vext_set_elems_1s(vd, vta, vl * 4, total_elems * 4); } + +static inline uint32_t sig0_sha256(uint32_t x) +{ + return ror32(x, 7) ^ ror32(x, 18) ^ (x >> 3); +} + +static inline uint32_t sig1_sha256(uint32_t x) +{ + return ror32(x, 17) ^ ror32(x, 19) ^ (x >> 10); +} + +static inline uint64_t sig0_sha512(uint64_t x) +{ + return ror64(x, 1) ^ ror64(x, 8) ^ (x >> 7); +} + +static inline uint64_t sig1_sha512(uint64_t x) +{ + return ror64(x, 19) ^ ror64(x, 61) ^ (x >> 6); +} + +static inline void vsha2ms_e32(uint32_t *vd, uint32_t *vs1, uint32_t *vs2) +{ + uint32_t res[4]; + res[0] =3D sig1_sha256(vs1[H4(2)]) + vs2[H4(1)] + sig0_sha256(vd[H4(1)= ]) + + vd[H4(0)]; + res[1] =3D sig1_sha256(vs1[H4(3)]) + vs2[H4(2)] + sig0_sha256(vd[H4(2)= ]) + + vd[H4(1)]; + res[2] =3D + sig1_sha256(res[0]) + vs2[H4(3)] + sig0_sha256(vd[H4(3)]) + vd[H4(= 2)]; + res[3] =3D + sig1_sha256(res[1]) + vs1[H4(0)] + sig0_sha256(vs2[H4(0)]) + vd[H4= (3)]; + vd[H4(3)] =3D res[3]; + vd[H4(2)] =3D res[2]; + vd[H4(1)] =3D res[1]; + vd[H4(0)] =3D res[0]; +} + +static inline void vsha2ms_e64(uint64_t *vd, uint64_t *vs1, uint64_t *vs2) +{ + uint64_t res[4]; + res[0] =3D sig1_sha512(vs1[2]) + vs2[1] + sig0_sha512(vd[1]) + vd[0]; + res[1] =3D sig1_sha512(vs1[3]) + vs2[2] + sig0_sha512(vd[2]) + vd[1]; + res[2] =3D sig1_sha512(res[0]) + vs2[3] + sig0_sha512(vd[3]) + vd[2]; + res[3] =3D sig1_sha512(res[1]) + vs1[0] + sig0_sha512(vs2[0]) + vd[3]; + vd[3] =3D res[3]; + vd[2] =3D res[2]; + vd[1] =3D res[1]; + vd[0] =3D res[0]; +} + +void HELPER(vsha2ms_vv)(void *vd, void *vs1, void *vs2, CPURISCVState *env, + uint32_t desc) +{ + uint32_t sew =3D FIELD_EX64(env->vtype, VTYPE, VSEW); + uint32_t esz =3D sew =3D=3D MO_32 ? 4 : 8; + uint32_t total_elems; + uint32_t vta =3D vext_vta(desc); + + for (uint32_t i =3D env->vstart / 4; i < env->vl / 4; i++) { + if (sew =3D=3D MO_32) { + vsha2ms_e32(((uint32_t *)vd) + i * 4, ((uint32_t *)vs1) + i * = 4, + ((uint32_t *)vs2) + i * 4); + } else { + /* If not 32 then SEW should be 64 */ + vsha2ms_e64(((uint64_t *)vd) + i * 4, ((uint64_t *)vs1) + i * = 4, + ((uint64_t *)vs2) + i * 4); + } + } + /* set tail elements to 1s */ + total_elems =3D vext_get_total_elems(env, desc, esz); + vext_set_elems_1s(vd, vta, env->vl * esz, total_elems * esz); + env->vstart =3D 0; +} + +static inline uint64_t sum0_64(uint64_t x) +{ + return ror64(x, 28) ^ ror64(x, 34) ^ ror64(x, 39); +} + +static inline uint32_t sum0_32(uint32_t x) +{ + return ror32(x, 2) ^ ror32(x, 13) ^ ror32(x, 22); +} + +static inline uint64_t sum1_64(uint64_t x) +{ + return ror64(x, 14) ^ ror64(x, 18) ^ ror64(x, 41); +} + +static inline uint32_t sum1_32(uint32_t x) +{ + return ror32(x, 6) ^ ror32(x, 11) ^ ror32(x, 25); +} + +#define ch(x, y, z) ((x & y) ^ ((~x) & z)) + +#define maj(x, y, z) ((x & y) ^ (x & z) ^ (y & z)) + +static void vsha2c_64(uint64_t *vs2, uint64_t *vd, uint64_t *vs1) +{ + uint64_t a =3D vs2[3], b =3D vs2[2], e =3D vs2[1], f =3D vs2[0]; + uint64_t c =3D vd[3], d =3D vd[2], g =3D vd[1], h =3D vd[0]; + uint64_t W0 =3D vs1[0], W1 =3D vs1[1]; + uint64_t T1 =3D h + sum1_64(e) + ch(e, f, g) + W0; + uint64_t T2 =3D sum0_64(a) + maj(a, b, c); + + h =3D g; + g =3D f; + f =3D e; + e =3D d + T1; + d =3D c; + c =3D b; + b =3D a; + a =3D T1 + T2; + + T1 =3D h + sum1_64(e) + ch(e, f, g) + W1; + T2 =3D sum0_64(a) + maj(a, b, c); + h =3D g; + g =3D f; + f =3D e; + e =3D d + T1; + d =3D c; + c =3D b; + b =3D a; + a =3D T1 + T2; + + vd[0] =3D f; + vd[1] =3D e; + vd[2] =3D b; + vd[3] =3D a; +} + +static void vsha2c_32(uint32_t *vs2, uint32_t *vd, uint32_t *vs1) +{ + uint32_t a =3D vs2[H4(3)], b =3D vs2[H4(2)], e =3D vs2[H4(1)], f =3D v= s2[H4(0)]; + uint32_t c =3D vd[H4(3)], d =3D vd[H4(2)], g =3D vd[H4(1)], h =3D vd[H= 4(0)]; + uint32_t W0 =3D vs1[H4(0)], W1 =3D vs1[H4(1)]; + uint32_t T1 =3D h + sum1_32(e) + ch(e, f, g) + W0; + uint32_t T2 =3D sum0_32(a) + maj(a, b, c); + + h =3D g; + g =3D f; + f =3D e; + e =3D d + T1; + d =3D c; + c =3D b; + b =3D a; + a =3D T1 + T2; + + T1 =3D h + sum1_32(e) + ch(e, f, g) + W1; + T2 =3D sum0_32(a) + maj(a, b, c); + h =3D g; + g =3D f; + f =3D e; + e =3D d + T1; + d =3D c; + c =3D b; + b =3D a; + a =3D T1 + T2; + + vd[H4(0)] =3D f; + vd[H4(1)] =3D e; + vd[H4(2)] =3D b; + vd[H4(3)] =3D a; +} + +void HELPER(vsha2ch32_vv)(void *vd, void *vs1, void *vs2, CPURISCVState *e= nv, + uint32_t desc) +{ + const uint32_t esz =3D 4; + uint32_t total_elems; + uint32_t vta =3D vext_vta(desc); + + for (uint32_t i =3D env->vstart / 4; i < env->vl / 4; i++) { + vsha2c_32(((uint32_t *)vs2) + 4 * i, ((uint32_t *)vd) + 4 * i, + ((uint32_t *)vs1) + 4 * i + 2); + } + + /* set tail elements to 1s */ + total_elems =3D vext_get_total_elems(env, desc, esz); + vext_set_elems_1s(vd, vta, env->vl * esz, total_elems * esz); + env->vstart =3D 0; +} + +void HELPER(vsha2ch64_vv)(void *vd, void *vs1, void *vs2, CPURISCVState *e= nv, + uint32_t desc) +{ + const uint32_t esz =3D 8; + uint32_t total_elems; + uint32_t vta =3D vext_vta(desc); + + for (uint32_t i =3D env->vstart / 4; i < env->vl / 4; i++) { + vsha2c_64(((uint64_t *)vs2) + 4 * i, ((uint64_t *)vd) + 4 * i, + ((uint64_t *)vs1) + 4 * i + 2); + } + + /* set tail elements to 1s */ + total_elems =3D vext_get_total_elems(env, desc, esz); + vext_set_elems_1s(vd, vta, env->vl * esz, total_elems * esz); + env->vstart =3D 0; +} + +void HELPER(vsha2cl32_vv)(void *vd, void *vs1, void *vs2, CPURISCVState *e= nv, + uint32_t desc) +{ + const uint32_t esz =3D 4; + uint32_t total_elems; + uint32_t vta =3D vext_vta(desc); + + for (uint32_t i =3D env->vstart / 4; i < env->vl / 4; i++) { + vsha2c_32(((uint32_t *)vs2) + 4 * i, ((uint32_t *)vd) + 4 * i, + (((uint32_t *)vs1) + 4 * i)); + } + + /* set tail elements to 1s */ + total_elems =3D vext_get_total_elems(env, desc, esz); + vext_set_elems_1s(vd, vta, env->vl * esz, total_elems * esz); + env->vstart =3D 0; +} + +void HELPER(vsha2cl64_vv)(void *vd, void *vs1, void *vs2, CPURISCVState *e= nv, + uint32_t desc) +{ + uint32_t esz =3D 8; + uint32_t total_elems; + uint32_t vta =3D vext_vta(desc); + + for (uint32_t i =3D env->vstart / 4; i < env->vl / 4; i++) { + vsha2c_64(((uint64_t *)vs2) + 4 * i, ((uint64_t *)vd) + 4 * i, + (((uint64_t *)vs1) + 4 * i)); + } + + /* set tail elements to 1s */ + total_elems =3D vext_get_total_elems(env, desc, esz); + vext_set_elems_1s(vd, vta, env->vl * esz, total_elems * esz); + env->vstart =3D 0; +} diff --git a/target/riscv/insn_trans/trans_rvvk.c.inc b/target/riscv/insn_t= rans/trans_rvvk.c.inc index 817353f4d3..a35be11b95 100644 --- a/target/riscv/insn_trans/trans_rvvk.c.inc +++ b/target/riscv/insn_trans/trans_rvvk.c.inc @@ -371,3 +371,132 @@ static bool vaeskf2_check(DisasContext *s, arg_vaeskf= 2_vi *a) =20 GEN_VI_UNMASKED_TRANS(vaeskf1_vi, vaeskf1_check, ZVKNED_EGS) GEN_VI_UNMASKED_TRANS(vaeskf2_vi, vaeskf2_check, ZVKNED_EGS) + +/* + * Zvknh + */ + +#define ZVKNH_EGS 4 + +#define GEN_VV_UNMASKED_TRANS(NAME, CHECK, EGS) = \ + static bool trans_##NAME(DisasContext *s, arg_rmrr *a) = \ + { = \ + if (CHECK(s, a)) { = \ + uint32_t data =3D 0; = \ + TCGLabel *over =3D gen_new_label(); = \ + TCGv_i32 egs; = \ + = \ + if (!s->vstart_eq_zero || !s->vl_eq_vlmax) { = \ + /* save opcode for unwinding in case we throw an exception= */ \ + decode_save_opc(s); = \ + egs =3D tcg_constant_i32(EGS); = \ + gen_helper_egs_check(egs, cpu_env); = \ + tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over);= \ + } = \ + = \ + data =3D FIELD_DP32(data, VDATA, VM, a->vm); = \ + data =3D FIELD_DP32(data, VDATA, LMUL, s->lmul); = \ + data =3D FIELD_DP32(data, VDATA, VTA, s->vta); = \ + data =3D FIELD_DP32(data, VDATA, VTA_ALL_1S, s->cfg_vta_all_1s= ); \ + data =3D FIELD_DP32(data, VDATA, VMA, s->vma); = \ + = \ + tcg_gen_gvec_3_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, a->rs1), = \ + vreg_ofs(s, a->rs2), cpu_env, = \ + s->cfg_ptr->vlen / 8, s->cfg_ptr->vlen / 8,= \ + data, gen_helper_##NAME); = \ + = \ + mark_vs_dirty(s); = \ + gen_set_label(over); = \ + return true; = \ + } = \ + return false; = \ + } + +static bool vsha_check_sew(DisasContext *s) +{ + return (s->cfg_ptr->ext_zvknha =3D=3D true && s->sew =3D=3D MO_32) || + (s->cfg_ptr->ext_zvknhb =3D=3D true && + (s->sew =3D=3D MO_32 || s->sew =3D=3D MO_64)); +} + +static bool vsha_check(DisasContext *s, arg_rmrr *a) +{ + int egw_bytes =3D ZVKNH_EGS << s->sew; + int mult =3D 1 << MAX(s->lmul, 0); + return opivv_check(s, a) && + vsha_check_sew(s) && + MAXSZ(s) >=3D egw_bytes && + !is_overlapped(a->rd, mult, a->rs1, mult) && + !is_overlapped(a->rd, mult, a->rs2, mult) && + s->lmul >=3D 0; +} + +GEN_VV_UNMASKED_TRANS(vsha2ms_vv, vsha_check, ZVKNH_EGS) + +static bool trans_vsha2cl_vv(DisasContext *s, arg_rmrr *a) +{ + if (vsha_check(s, a)) { + uint32_t data =3D 0; + TCGLabel *over =3D gen_new_label(); + TCGv_i32 egs; + + if (!s->vstart_eq_zero || !s->vl_eq_vlmax) { + /* save opcode for unwinding in case we throw an exception */ + decode_save_opc(s); + egs =3D tcg_constant_i32(ZVKNH_EGS); + gen_helper_egs_check(egs, cpu_env); + tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); + } + + data =3D FIELD_DP32(data, VDATA, VM, a->vm); + data =3D FIELD_DP32(data, VDATA, LMUL, s->lmul); + data =3D FIELD_DP32(data, VDATA, VTA, s->vta); + data =3D FIELD_DP32(data, VDATA, VTA_ALL_1S, s->cfg_vta_all_1s); + data =3D FIELD_DP32(data, VDATA, VMA, s->vma); + + tcg_gen_gvec_3_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, a->rs1), + vreg_ofs(s, a->rs2), cpu_env, s->cfg_ptr->vlen / 8, + s->cfg_ptr->vlen / 8, data, + s->sew =3D=3D MO_32 ? + gen_helper_vsha2cl32_vv : gen_helper_vsha2cl64_vv); + + mark_vs_dirty(s); + gen_set_label(over); + return true; + } + return false; +} + +static bool trans_vsha2ch_vv(DisasContext *s, arg_rmrr *a) +{ + if (vsha_check(s, a)) { + uint32_t data =3D 0; + TCGLabel *over =3D gen_new_label(); + TCGv_i32 egs; + + if (!s->vstart_eq_zero || !s->vl_eq_vlmax) { + /* save opcode for unwinding in case we throw an exception */ + decode_save_opc(s); + egs =3D tcg_constant_i32(ZVKNH_EGS); + gen_helper_egs_check(egs, cpu_env); + tcg_gen_brcond_tl(TCG_COND_GEU, cpu_vstart, cpu_vl, over); + } + + data =3D FIELD_DP32(data, VDATA, VM, a->vm); + data =3D FIELD_DP32(data, VDATA, LMUL, s->lmul); + data =3D FIELD_DP32(data, VDATA, VTA, s->vta); + data =3D FIELD_DP32(data, VDATA, VTA_ALL_1S, s->cfg_vta_all_1s); + data =3D FIELD_DP32(data, VDATA, VMA, s->vma); + + tcg_gen_gvec_3_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, a->rs1), + vreg_ofs(s, a->rs2), cpu_env, s->cfg_ptr->vlen / 8, + s->cfg_ptr->vlen / 8, data, + s->sew =3D=3D MO_32 ? + gen_helper_vsha2ch32_vv : gen_helper_vsha2ch64_vv); + + mark_vs_dirty(s); + gen_set_label(over); + return true; + } + return false; +} --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153480; cv=none; d=zohomail.com; s=zohoarc; b=jVwlOP7KmnZ6iNr7VnTmBVVeWPuVMOvOkzZFDawWLN/Ko9soZJKsOHqA+tQfm9U7IeJ2E580nePl1OEmTHYEh8LIPHSU4SmsW9PVF9mVFN/b0HGcOMOQUh6bM5UtRpXkSD0GNyi/AK0CtopUNMP4gxtamocrGMkOHmXzGY5lFus= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153480; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Lv6oPKSscriAWzY9S4BIB1qr2a57kfHqu5E/DrqopIo=; b=DohLLlmRyUbJf3udli5vDxTOM8jdfhdXBS+t8qCEygyoUne3Tk5pJiv/dflxBofDUps/CEzcWoq/ccnUyyQsJ8lSdF4IoGqBe4pvWIbso+I1011HdM7pC4xXOFZkCKOFnKyXtTCWPL/e8cob85czNqq6A/T0xujq7wY8hICwcH4= 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 1694153480924119.61187068077663; Thu, 7 Sep 2023 23:11:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUdY-0001pl-GV; Fri, 08 Sep 2023 02:06:36 -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 1qeUdA-0000y1-Lo for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:15 -0400 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 1qeUd5-0005jy-PF for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:12 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1c0ecb9a075so13479135ad.2 for ; Thu, 07 Sep 2023 23:06:07 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.06.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:06:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153166; x=1694757966; 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=Lv6oPKSscriAWzY9S4BIB1qr2a57kfHqu5E/DrqopIo=; b=ebDWR9bqbD2HmYoubb9XMn9FthVfv4vNTHYzIlQNHFmrx1AW+G5Bo/XTk9RwoxgPjg YX3346YwKLJY8+yhfZFXuaXnMqqRIrTGlXgqz47GhHzYZgKwrtyTHDHLZn8aJxfBhcAt aTyye5YZdhxwsKSeyKtq1auF8sriik3ZViU8V2FgOjdnhSnQesgGyxTIRA+3Eu2/VCvw WC3/uNPc163Z8/EyBOGl3Tm/6ULHq3A3SGWmRQfYxrDY5cie+DtrLOejpcATcEsMuVTg pIuLRR9sT3Dhuo5dkddu98l6RjwghRdtC+zYmTfO7Z3W0TzV/JBwf85iO1cH3f2KtjDP 6cEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153166; x=1694757966; 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=Lv6oPKSscriAWzY9S4BIB1qr2a57kfHqu5E/DrqopIo=; b=psJY5ovSn9f3LzRNF3zMnf17a1NmjDBrJjq2ip3YueecXIF4Jf1IwXN91K8QxbXZPl q1WrD6317sGiwko5QutVzBd9PXlIVBHvOXEffnGkvKJkgVaX8i1nRo5QkpWLVI524LD+ EYPftRq16JGZsyS8EGx+DC9LoB/NpTgeyuqWU5SCLSlfzSPxHT+I/N6lCS9sB1RTXLtR ib0LhsYae2CO9Jsv9WC+LvPGtElDayAe2Y3Qsm+A7Wn0hciKYajouppwxlKM4ubsrMdS DyCxgC6VVJ+Bfnd6uYOHolAlu6gCCyLGJE1O6I0sVtYwFYARZJi6czTM5spn9oW9ZtLW +vhA== X-Gm-Message-State: AOJu0YzJyUO7w1u9+J9eilpl/WXJsMX89mTjXfzopYitFEiZJHftqN1z SDJP1i/LF0KtqzB5j7/Bi7Fkm45D7x/JsfiX X-Google-Smtp-Source: AGHT+IH0PJyJAqIRiOIAFAWEN7DmDYO9UduMASh4nQ7D4C1bYkkhCL/P/3SGslQlAVwXW0342rGZ5w== X-Received: by 2002:a17:902:b494:b0:1c0:ecbb:1831 with SMTP id y20-20020a170902b49400b001c0ecbb1831mr1579350plr.16.1694153166049; Thu, 07 Sep 2023 23:06:06 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Lawrence Hunter , Kiran Ostrolenk , Max Chou , Daniel Henrique Barboza , Alistair Francis Subject: [PULL 18/65] target/riscv: Add Zvksh ISA extension support Date: Fri, 8 Sep 2023 16:03:44 +1000 Message-ID: <20230908060431.1903919-19-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::62f; envelope-from=alistair23@gmail.com; helo=mail-pl1-x62f.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: 1694153483161100009 Content-Type: text/plain; charset="utf-8" From: Lawrence Hunter This commit adds support for the Zvksh vector-crypto extension, which consists of the following instructions: * vsm3me.vv * vsm3c.vi Translation functions are defined in `target/riscv/insn_trans/trans_rvvk.c.inc` and helpers are defined in `target/riscv/vcrypto_helper.c`. Co-authored-by: Kiran Ostrolenk [max.chou@sifive.com: Replaced vstart checking by TCG op] Signed-off-by: Kiran Ostrolenk Signed-off-by: Lawrence Hunter Signed-off-by: Max Chou Reviewed-by: Daniel Henrique Barboza [max.chou@sifive.com: Exposed x-zvksh property] Message-ID: <20230711165917.2629866-12-max.chou@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/cpu_cfg.h | 1 + target/riscv/helper.h | 3 + target/riscv/insn32.decode | 4 + target/riscv/cpu.c | 6 +- target/riscv/vcrypto_helper.c | 134 +++++++++++++++++++++++ target/riscv/insn_trans/trans_rvvk.c.inc | 31 ++++++ 6 files changed, 177 insertions(+), 2 deletions(-) diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h index 800b8783c1..ab2d9294db 100644 --- a/target/riscv/cpu_cfg.h +++ b/target/riscv/cpu_cfg.h @@ -90,6 +90,7 @@ struct RISCVCPUConfig { bool ext_zvkned; bool ext_zvknha; bool ext_zvknhb; + bool ext_zvksh; bool ext_zmmul; bool ext_zvfbfmin; bool ext_zvfbfwma; diff --git a/target/riscv/helper.h b/target/riscv/helper.h index 34329b52fe..6d21347c39 100644 --- a/target/riscv/helper.h +++ b/target/riscv/helper.h @@ -1270,3 +1270,6 @@ DEF_HELPER_5(vsha2ch32_vv, void, ptr, ptr, ptr, env, = i32) DEF_HELPER_5(vsha2ch64_vv, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vsha2cl32_vv, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vsha2cl64_vv, void, ptr, ptr, ptr, env, i32) + +DEF_HELPER_5(vsm3me_vv, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_5(vsm3c_vi, void, ptr, ptr, i32, env, i32) diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode index e2b83186dc..4050e843f7 100644 --- a/target/riscv/insn32.decode +++ b/target/riscv/insn32.decode @@ -991,3 +991,7 @@ vaeskf2_vi 101010 1 ..... ..... 010 ..... 1110111 @r_v= m_1 vsha2ms_vv 101101 1 ..... ..... 010 ..... 1110111 @r_vm_1 vsha2ch_vv 101110 1 ..... ..... 010 ..... 1110111 @r_vm_1 vsha2cl_vv 101111 1 ..... ..... 010 ..... 1110111 @r_vm_1 + +# *** Zvksh vector crypto extension *** +vsm3me_vv 100000 1 ..... ..... 010 ..... 1110111 @r_vm_1 +vsm3c_vi 101011 1 ..... ..... 010 ..... 1110111 @r_vm_1 diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index f103f536fd..ce0d32eef3 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -132,6 +132,7 @@ static const struct isa_ext_data isa_edata_arr[] =3D { ISA_EXT_DATA_ENTRY(zvkned, PRIV_VERSION_1_12_0, ext_zvkned), ISA_EXT_DATA_ENTRY(zvknha, PRIV_VERSION_1_12_0, ext_zvknha), ISA_EXT_DATA_ENTRY(zvknhb, PRIV_VERSION_1_12_0, ext_zvknhb), + ISA_EXT_DATA_ENTRY(zvksh, PRIV_VERSION_1_12_0, ext_zvksh), ISA_EXT_DATA_ENTRY(zhinx, PRIV_VERSION_1_12_0, ext_zhinx), ISA_EXT_DATA_ENTRY(zhinxmin, PRIV_VERSION_1_12_0, ext_zhinxmin), ISA_EXT_DATA_ENTRY(smaia, PRIV_VERSION_1_12_0, ext_smaia), @@ -1280,8 +1281,8 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu,= Error **errp) * In principle Zve*x would also suffice here, were they supported * in qemu */ - if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkned || cpu->cfg.ext_zvknha) = && - !cpu->cfg.ext_zve32f) { + if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkned || cpu->cfg.ext_zvknha || + cpu->cfg.ext_zvksh) && !cpu->cfg.ext_zve32f) { error_setg(errp, "Vector crypto extensions require V or Zve* extensions"= ); return; @@ -1882,6 +1883,7 @@ static Property riscv_cpu_extensions[] =3D { DEFINE_PROP_BOOL("x-zvkned", RISCVCPU, cfg.ext_zvkned, false), DEFINE_PROP_BOOL("x-zvknha", RISCVCPU, cfg.ext_zvknha, false), DEFINE_PROP_BOOL("x-zvknhb", RISCVCPU, cfg.ext_zvknhb, false), + DEFINE_PROP_BOOL("x-zvksh", RISCVCPU, cfg.ext_zvksh, false), =20 DEFINE_PROP_END_OF_LIST(), }; diff --git a/target/riscv/vcrypto_helper.c b/target/riscv/vcrypto_helper.c index 2f2099b6fb..e8bbb698c1 100644 --- a/target/riscv/vcrypto_helper.c +++ b/target/riscv/vcrypto_helper.c @@ -635,3 +635,137 @@ void HELPER(vsha2cl64_vv)(void *vd, void *vs1, void *= vs2, CPURISCVState *env, vext_set_elems_1s(vd, vta, env->vl * esz, total_elems * esz); env->vstart =3D 0; } + +static inline uint32_t p1(uint32_t x) +{ + return x ^ rol32(x, 15) ^ rol32(x, 23); +} + +static inline uint32_t zvksh_w(uint32_t m16, uint32_t m9, uint32_t m3, + uint32_t m13, uint32_t m6) +{ + return p1(m16 ^ m9 ^ rol32(m3, 15)) ^ rol32(m13, 7) ^ m6; +} + +void HELPER(vsm3me_vv)(void *vd_vptr, void *vs1_vptr, void *vs2_vptr, + CPURISCVState *env, uint32_t desc) +{ + uint32_t esz =3D memop_size(FIELD_EX64(env->vtype, VTYPE, VSEW)); + uint32_t total_elems =3D vext_get_total_elems(env, desc, esz); + uint32_t vta =3D vext_vta(desc); + uint32_t *vd =3D vd_vptr; + uint32_t *vs1 =3D vs1_vptr; + uint32_t *vs2 =3D vs2_vptr; + + for (int i =3D env->vstart / 8; i < env->vl / 8; i++) { + uint32_t w[24]; + for (int j =3D 0; j < 8; j++) { + w[j] =3D bswap32(vs1[H4((i * 8) + j)]); + w[j + 8] =3D bswap32(vs2[H4((i * 8) + j)]); + } + for (int j =3D 0; j < 8; j++) { + w[j + 16] =3D + zvksh_w(w[j], w[j + 7], w[j + 13], w[j + 3], w[j + 10]); + } + for (int j =3D 0; j < 8; j++) { + vd[(i * 8) + j] =3D bswap32(w[H4(j + 16)]); + } + } + vext_set_elems_1s(vd_vptr, vta, env->vl * esz, total_elems * esz); + env->vstart =3D 0; +} + +static inline uint32_t ff1(uint32_t x, uint32_t y, uint32_t z) +{ + return x ^ y ^ z; +} + +static inline uint32_t ff2(uint32_t x, uint32_t y, uint32_t z) +{ + return (x & y) | (x & z) | (y & z); +} + +static inline uint32_t ff_j(uint32_t x, uint32_t y, uint32_t z, uint32_t j) +{ + return (j <=3D 15) ? ff1(x, y, z) : ff2(x, y, z); +} + +static inline uint32_t gg1(uint32_t x, uint32_t y, uint32_t z) +{ + return x ^ y ^ z; +} + +static inline uint32_t gg2(uint32_t x, uint32_t y, uint32_t z) +{ + return (x & y) | (~x & z); +} + +static inline uint32_t gg_j(uint32_t x, uint32_t y, uint32_t z, uint32_t j) +{ + return (j <=3D 15) ? gg1(x, y, z) : gg2(x, y, z); +} + +static inline uint32_t t_j(uint32_t j) +{ + return (j <=3D 15) ? 0x79cc4519 : 0x7a879d8a; +} + +static inline uint32_t p_0(uint32_t x) +{ + return x ^ rol32(x, 9) ^ rol32(x, 17); +} + +static void sm3c(uint32_t *vd, uint32_t *vs1, uint32_t *vs2, uint32_t uimm) +{ + uint32_t x0, x1; + uint32_t j; + uint32_t ss1, ss2, tt1, tt2; + x0 =3D vs2[0] ^ vs2[4]; + x1 =3D vs2[1] ^ vs2[5]; + j =3D 2 * uimm; + ss1 =3D rol32(rol32(vs1[0], 12) + vs1[4] + rol32(t_j(j), j % 32), 7); + ss2 =3D ss1 ^ rol32(vs1[0], 12); + tt1 =3D ff_j(vs1[0], vs1[1], vs1[2], j) + vs1[3] + ss2 + x0; + tt2 =3D gg_j(vs1[4], vs1[5], vs1[6], j) + vs1[7] + ss1 + vs2[0]; + vs1[3] =3D vs1[2]; + vd[3] =3D rol32(vs1[1], 9); + vs1[1] =3D vs1[0]; + vd[1] =3D tt1; + vs1[7] =3D vs1[6]; + vd[7] =3D rol32(vs1[5], 19); + vs1[5] =3D vs1[4]; + vd[5] =3D p_0(tt2); + j =3D 2 * uimm + 1; + ss1 =3D rol32(rol32(vd[1], 12) + vd[5] + rol32(t_j(j), j % 32), 7); + ss2 =3D ss1 ^ rol32(vd[1], 12); + tt1 =3D ff_j(vd[1], vs1[1], vd[3], j) + vs1[3] + ss2 + x1; + tt2 =3D gg_j(vd[5], vs1[5], vd[7], j) + vs1[7] + ss1 + vs2[1]; + vd[2] =3D rol32(vs1[1], 9); + vd[0] =3D tt1; + vd[6] =3D rol32(vs1[5], 19); + vd[4] =3D p_0(tt2); +} + +void HELPER(vsm3c_vi)(void *vd_vptr, void *vs2_vptr, uint32_t uimm, + CPURISCVState *env, uint32_t desc) +{ + uint32_t esz =3D memop_size(FIELD_EX64(env->vtype, VTYPE, VSEW)); + uint32_t total_elems =3D vext_get_total_elems(env, desc, esz); + uint32_t vta =3D vext_vta(desc); + uint32_t *vd =3D vd_vptr; + uint32_t *vs2 =3D vs2_vptr; + uint32_t v1[8], v2[8], v3[8]; + + for (int i =3D env->vstart / 8; i < env->vl / 8; i++) { + for (int k =3D 0; k < 8; k++) { + v2[k] =3D bswap32(vd[H4(i * 8 + k)]); + v3[k] =3D bswap32(vs2[H4(i * 8 + k)]); + } + sm3c(v1, v2, v3, uimm); + for (int k =3D 0; k < 8; k++) { + vd[i * 8 + k] =3D bswap32(v1[H4(k)]); + } + } + vext_set_elems_1s(vd_vptr, vta, env->vl * esz, total_elems * esz); + env->vstart =3D 0; +} diff --git a/target/riscv/insn_trans/trans_rvvk.c.inc b/target/riscv/insn_t= rans/trans_rvvk.c.inc index a35be11b95..6469dd2f02 100644 --- a/target/riscv/insn_trans/trans_rvvk.c.inc +++ b/target/riscv/insn_trans/trans_rvvk.c.inc @@ -500,3 +500,34 @@ static bool trans_vsha2ch_vv(DisasContext *s, arg_rmrr= *a) } return false; } + +/* + * Zvksh + */ + +#define ZVKSH_EGS 8 + +static inline bool vsm3_check(DisasContext *s, arg_rmrr *a) +{ + int egw_bytes =3D ZVKSH_EGS << s->sew; + int mult =3D 1 << MAX(s->lmul, 0); + return s->cfg_ptr->ext_zvksh =3D=3D true && + require_rvv(s) && + vext_check_isa_ill(s) && + !is_overlapped(a->rd, mult, a->rs2, mult) && + MAXSZ(s) >=3D egw_bytes && + s->sew =3D=3D MO_32; +} + +static inline bool vsm3me_check(DisasContext *s, arg_rmrr *a) +{ + return vsm3_check(s, a) && vext_check_sss(s, a->rd, a->rs1, a->rs2, a-= >vm); +} + +static inline bool vsm3c_check(DisasContext *s, arg_rmrr *a) +{ + return vsm3_check(s, a) && vext_check_ss(s, a->rd, a->rs2, a->vm); +} + +GEN_VV_UNMASKED_TRANS(vsm3me_vv, vsm3me_check, ZVKSH_EGS) +GEN_VI_UNMASKED_TRANS(vsm3c_vi, vsm3c_check, ZVKSH_EGS) --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153296; cv=none; d=zohomail.com; s=zohoarc; b=M2Gb8QbSWXCYoNZN5OYuluadbG8Y8fmk4l1uki+3HNQaPNSDY6Z0736RyUSGBJroRFWTPSQjUBgUduMlNQGkVVjnpQ1BEaOv/quB7pym83vYY1Ns0JAZR2ZYH/TebeEc4GO1aChUm1q+VZZId0kN7TKp+NzQeDdg0+E6gs/ONhE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153296; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CG534oqdKvZg93XhHJTveosyzNAkM7GvLcEv8iTROyU=; b=Y/SkV28QIBQQcvOFtKOBUNFdtbOkJen8wAnCC0xH5kdW7LpFSIFG/vA1H34g9ltclr/RxEnEw1pqhc0zquRlOQ85YNQf9owTWdqBcS1KCPDHNUiy8QDZDJgC2wdxSlJMmoiqqaXphQjsBtaWK1qjONb6WyU6MK32Y6a6925dIl8= 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 169415329697753.99336571782408; Thu, 7 Sep 2023 23:08:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUdV-0001OA-Di; Fri, 08 Sep 2023 02:06:33 -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 1qeUdE-00013N-KB for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:24 -0400 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 1qeUdA-0005pJ-Di for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:15 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1c336f3f449so14693465ad.3 for ; Thu, 07 Sep 2023 23:06:11 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.06.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:06:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153170; x=1694757970; 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=CG534oqdKvZg93XhHJTveosyzNAkM7GvLcEv8iTROyU=; b=sAzMDNjCifc1m3K+4iqZZflMerUo8s5p1SyvoPLjiVL+Pzg7dQc5VlbvXGCkB8HQt2 pIYdklv8JTmEINE/1qrsTbApvxnIgwUeZRK+hhAtLmAo3w7MwbqNJzLrY7W/GVQGYhrX WfOhn/JaV5HqxmmivQFvloxVJp4/hlp9lPL7gshxCZBrBr6ztHWRsWN38Xk6ua9qNRE5 dxQuPBDu7UB7Wubb5wBhSkdWN+xSi0tvYUBVQGKab/o6JUPGIXh1O8ieko2jh1Xz8Sdz lSEkrQnOMksGd4uerA0rtq0ZX1+tzxsKDdpFmR7nXmTnFp1u9gkh+di2nUnkXJiExfDh 0PRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153170; x=1694757970; 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=CG534oqdKvZg93XhHJTveosyzNAkM7GvLcEv8iTROyU=; b=PSaPEpRBHE7HabryASWKkCrNcPqPgVFltP0x2sJwlc7UbTKV2sw8B5D2T/PD4kSpNe 8spRLCdtrcYCP6P/GCvbgUmr7xOOxJFKPUHz3HCELXy6Tz5t92xaWA3qi1RMgm6K8aHQ LcWotgA4Vk4O+pQVttCrtoYmKinc1ukowR7U/5fcHna626osRG9QZoGbsLr2zKfHr+l7 k+/q5IDoGNSK45snXrBfq3T0gjCzJLnaWekZXEAQtmDYpeb9cQnzyg8kYyNQoga6/eSO bYnldFjtUzlu99z8IhHZBRW1EN2+nDXP04NYDJgDIBZz8ZBiBo89is/i+mH7JHkWFnqs fRUg== X-Gm-Message-State: AOJu0YycnUKq2qAGP+25oSyC0gTFVJNCcOimg8Nko+npZb2+cHfkA2CT rW3C99JwXrgVTZzHG9OdmigvNSU9xxr+QLhY X-Google-Smtp-Source: AGHT+IFvDqjm1rHPRh3CjDN+3ppUb0T6ftkI1aYjB7JTJxY6oD/M1tNMvNhqm0pHGc0vmChleH4QWQ== X-Received: by 2002:a17:902:a5c7:b0:1c0:6dcd:453d with SMTP id t7-20020a170902a5c700b001c06dcd453dmr1541767plq.20.1694153170098; Thu, 07 Sep 2023 23:06:10 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Nazar Kazakov , Lawrence Hunter , Max Chou , Daniel Henrique Barboza , Alistair Francis Subject: [PULL 19/65] target/riscv: Add Zvkg ISA extension support Date: Fri, 8 Sep 2023 16:03:45 +1000 Message-ID: <20230908060431.1903919-20-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::629; envelope-from=alistair23@gmail.com; helo=mail-pl1-x629.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: 1694153298821100003 Content-Type: text/plain; charset="utf-8" From: Nazar Kazakov This commit adds support for the Zvkg vector-crypto extension, which consists of the following instructions: * vgmul.vv * vghsh.vv Translation functions are defined in `target/riscv/insn_trans/trans_rvvk.c.inc` and helpers are defined in `target/riscv/vcrypto_helper.c`. Co-authored-by: Lawrence Hunter [max.chou@sifive.com: Replaced vstart checking by TCG op] Signed-off-by: Lawrence Hunter Signed-off-by: Nazar Kazakov Signed-off-by: Max Chou Reviewed-by: Daniel Henrique Barboza [max.chou@sifive.com: Exposed x-zvkg property] [max.chou@sifive.com: Replaced uint by int for cross win32 build] Message-ID: <20230711165917.2629866-13-max.chou@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/cpu_cfg.h | 1 + target/riscv/helper.h | 3 + target/riscv/insn32.decode | 4 ++ target/riscv/cpu.c | 6 +- target/riscv/vcrypto_helper.c | 72 ++++++++++++++++++++++++ target/riscv/insn_trans/trans_rvvk.c.inc | 30 ++++++++++ 6 files changed, 114 insertions(+), 2 deletions(-) diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h index ab2d9294db..b754ec2344 100644 --- a/target/riscv/cpu_cfg.h +++ b/target/riscv/cpu_cfg.h @@ -87,6 +87,7 @@ struct RISCVCPUConfig { bool ext_zve64d; bool ext_zvbb; bool ext_zvbc; + bool ext_zvkg; bool ext_zvkned; bool ext_zvknha; bool ext_zvknhb; diff --git a/target/riscv/helper.h b/target/riscv/helper.h index 6d21347c39..ceec97e165 100644 --- a/target/riscv/helper.h +++ b/target/riscv/helper.h @@ -1273,3 +1273,6 @@ DEF_HELPER_5(vsha2cl64_vv, void, ptr, ptr, ptr, env, = i32) =20 DEF_HELPER_5(vsm3me_vv, void, ptr, ptr, ptr, env, i32) DEF_HELPER_5(vsm3c_vi, void, ptr, ptr, i32, env, i32) + +DEF_HELPER_5(vghsh_vv, void, ptr, ptr, ptr, env, i32) +DEF_HELPER_4(vgmul_vv, void, ptr, ptr, env, i32) diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode index 4050e843f7..0fae01c6bb 100644 --- a/target/riscv/insn32.decode +++ b/target/riscv/insn32.decode @@ -995,3 +995,7 @@ vsha2cl_vv 101111 1 ..... ..... 010 ..... 1110111 @r_v= m_1 # *** Zvksh vector crypto extension *** vsm3me_vv 100000 1 ..... ..... 010 ..... 1110111 @r_vm_1 vsm3c_vi 101011 1 ..... ..... 010 ..... 1110111 @r_vm_1 + +# *** Zvkg vector crypto extension *** +vghsh_vv 101100 1 ..... ..... 010 ..... 1110111 @r_vm_1 +vgmul_vv 101000 1 ..... 10001 010 ..... 1110111 @r2_vm_1 diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index ce0d32eef3..981907c033 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -129,6 +129,7 @@ static const struct isa_ext_data isa_edata_arr[] =3D { ISA_EXT_DATA_ENTRY(zvfbfwma, PRIV_VERSION_1_12_0, ext_zvfbfwma), ISA_EXT_DATA_ENTRY(zvfh, PRIV_VERSION_1_12_0, ext_zvfh), ISA_EXT_DATA_ENTRY(zvfhmin, PRIV_VERSION_1_12_0, ext_zvfhmin), + ISA_EXT_DATA_ENTRY(zvkg, PRIV_VERSION_1_12_0, ext_zvkg), ISA_EXT_DATA_ENTRY(zvkned, PRIV_VERSION_1_12_0, ext_zvkned), ISA_EXT_DATA_ENTRY(zvknha, PRIV_VERSION_1_12_0, ext_zvknha), ISA_EXT_DATA_ENTRY(zvknhb, PRIV_VERSION_1_12_0, ext_zvknhb), @@ -1281,8 +1282,8 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu,= Error **errp) * In principle Zve*x would also suffice here, were they supported * in qemu */ - if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkned || cpu->cfg.ext_zvknha || - cpu->cfg.ext_zvksh) && !cpu->cfg.ext_zve32f) { + if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkg || cpu->cfg.ext_zvkned || + cpu->cfg.ext_zvknha || cpu->cfg.ext_zvksh) && !cpu->cfg.ext_zve32= f) { error_setg(errp, "Vector crypto extensions require V or Zve* extensions"= ); return; @@ -1880,6 +1881,7 @@ static Property riscv_cpu_extensions[] =3D { /* Vector cryptography extensions */ DEFINE_PROP_BOOL("x-zvbb", RISCVCPU, cfg.ext_zvbb, false), DEFINE_PROP_BOOL("x-zvbc", RISCVCPU, cfg.ext_zvbc, false), + DEFINE_PROP_BOOL("x-zvkg", RISCVCPU, cfg.ext_zvkg, false), DEFINE_PROP_BOOL("x-zvkned", RISCVCPU, cfg.ext_zvkned, false), DEFINE_PROP_BOOL("x-zvknha", RISCVCPU, cfg.ext_zvknha, false), DEFINE_PROP_BOOL("x-zvknhb", RISCVCPU, cfg.ext_zvknhb, false), diff --git a/target/riscv/vcrypto_helper.c b/target/riscv/vcrypto_helper.c index e8bbb698c1..a5e2f7fbb0 100644 --- a/target/riscv/vcrypto_helper.c +++ b/target/riscv/vcrypto_helper.c @@ -769,3 +769,75 @@ void HELPER(vsm3c_vi)(void *vd_vptr, void *vs2_vptr, u= int32_t uimm, vext_set_elems_1s(vd_vptr, vta, env->vl * esz, total_elems * esz); env->vstart =3D 0; } + +void HELPER(vghsh_vv)(void *vd_vptr, void *vs1_vptr, void *vs2_vptr, + CPURISCVState *env, uint32_t desc) +{ + uint64_t *vd =3D vd_vptr; + uint64_t *vs1 =3D vs1_vptr; + uint64_t *vs2 =3D vs2_vptr; + uint32_t vta =3D vext_vta(desc); + uint32_t total_elems =3D vext_get_total_elems(env, desc, 4); + + for (uint32_t i =3D env->vstart / 4; i < env->vl / 4; i++) { + uint64_t Y[2] =3D {vd[i * 2 + 0], vd[i * 2 + 1]}; + uint64_t H[2] =3D {brev8(vs2[i * 2 + 0]), brev8(vs2[i * 2 + 1])}; + uint64_t X[2] =3D {vs1[i * 2 + 0], vs1[i * 2 + 1]}; + uint64_t Z[2] =3D {0, 0}; + + uint64_t S[2] =3D {brev8(Y[0] ^ X[0]), brev8(Y[1] ^ X[1])}; + + for (int j =3D 0; j < 128; j++) { + if ((S[j / 64] >> (j % 64)) & 1) { + Z[0] ^=3D H[0]; + Z[1] ^=3D H[1]; + } + bool reduce =3D ((H[1] >> 63) & 1); + H[1] =3D H[1] << 1 | H[0] >> 63; + H[0] =3D H[0] << 1; + if (reduce) { + H[0] ^=3D 0x87; + } + } + + vd[i * 2 + 0] =3D brev8(Z[0]); + vd[i * 2 + 1] =3D brev8(Z[1]); + } + /* set tail elements to 1s */ + vext_set_elems_1s(vd, vta, env->vl * 4, total_elems * 4); + env->vstart =3D 0; +} + +void HELPER(vgmul_vv)(void *vd_vptr, void *vs2_vptr, CPURISCVState *env, + uint32_t desc) +{ + uint64_t *vd =3D vd_vptr; + uint64_t *vs2 =3D vs2_vptr; + uint32_t vta =3D vext_vta(desc); + uint32_t total_elems =3D vext_get_total_elems(env, desc, 4); + + for (uint32_t i =3D env->vstart / 4; i < env->vl / 4; i++) { + uint64_t Y[2] =3D {brev8(vd[i * 2 + 0]), brev8(vd[i * 2 + 1])}; + uint64_t H[2] =3D {brev8(vs2[i * 2 + 0]), brev8(vs2[i * 2 + 1])}; + uint64_t Z[2] =3D {0, 0}; + + for (int j =3D 0; j < 128; j++) { + if ((Y[j / 64] >> (j % 64)) & 1) { + Z[0] ^=3D H[0]; + Z[1] ^=3D H[1]; + } + bool reduce =3D ((H[1] >> 63) & 1); + H[1] =3D H[1] << 1 | H[0] >> 63; + H[0] =3D H[0] << 1; + if (reduce) { + H[0] ^=3D 0x87; + } + } + + vd[i * 2 + 0] =3D brev8(Z[0]); + vd[i * 2 + 1] =3D brev8(Z[1]); + } + /* set tail elements to 1s */ + vext_set_elems_1s(vd, vta, env->vl * 4, total_elems * 4); + env->vstart =3D 0; +} diff --git a/target/riscv/insn_trans/trans_rvvk.c.inc b/target/riscv/insn_t= rans/trans_rvvk.c.inc index 6469dd2f02..af7cd62e7d 100644 --- a/target/riscv/insn_trans/trans_rvvk.c.inc +++ b/target/riscv/insn_trans/trans_rvvk.c.inc @@ -531,3 +531,33 @@ static inline bool vsm3c_check(DisasContext *s, arg_rm= rr *a) =20 GEN_VV_UNMASKED_TRANS(vsm3me_vv, vsm3me_check, ZVKSH_EGS) GEN_VI_UNMASKED_TRANS(vsm3c_vi, vsm3c_check, ZVKSH_EGS) + +/* + * Zvkg + */ + +#define ZVKG_EGS 4 + +static bool vgmul_check(DisasContext *s, arg_rmr *a) +{ + int egw_bytes =3D ZVKG_EGS << s->sew; + return s->cfg_ptr->ext_zvkg =3D=3D true && + vext_check_isa_ill(s) && + require_rvv(s) && + MAXSZ(s) >=3D egw_bytes && + vext_check_ss(s, a->rd, a->rs2, a->vm) && + s->sew =3D=3D MO_32; +} + +GEN_V_UNMASKED_TRANS(vgmul_vv, vgmul_check, ZVKG_EGS) + +static bool vghsh_check(DisasContext *s, arg_rmrr *a) +{ + int egw_bytes =3D ZVKG_EGS << s->sew; + return s->cfg_ptr->ext_zvkg =3D=3D true && + opivv_check(s, a) && + MAXSZ(s) >=3D egw_bytes && + s->sew =3D=3D MO_32; +} + +GEN_VV_UNMASKED_TRANS(vghsh_vv, vghsh_check, ZVKG_EGS) --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153292; cv=none; d=zohomail.com; s=zohoarc; b=NmndXhuEekH3bryZovNTxo2IoPgCqJutBgCHkzWO+RzDzduN/66oCS2N+8kUtTgPuML1xKQu9kAGnukpfUmcZtFsy2bWhmxVyHVLN9tzf3eZubD7tfFsbEQWBKgtUKYiQ1sfUS7p8Li3Wp/hM/piB/V0yMUdEkIERKyF+NHYAOw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153292; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KTZoQQBHRX8Eh4+DjB2iRGNyN+rFo0jz7PJ5kMgxxIY=; b=UlXtjdon4G86Dj0BxvhXP9HRycNkNHbmYYgCBjF69dCltreEVzzH9OjzMeCcbN5GN/t27XbWyfsWUGsvqitZeeb2MvyqYq8iPS/J53FLh2srMc+/DN0xMk+mheSVHMOx+CSic8RkBRk4Ip7D6sx/wpkyRQX4xGTM+hK0unbekNE= 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 1694153292638935.9234475006853; Thu, 7 Sep 2023 23:08:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUdX-0001h4-I3; Fri, 08 Sep 2023 02:06:35 -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 1qeUdH-00014D-Gt for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:25 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUdD-0005r5-UE for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:19 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1c09673b006so13016985ad.1 for ; Thu, 07 Sep 2023 23:06:15 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.06.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:06:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153174; x=1694757974; 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=KTZoQQBHRX8Eh4+DjB2iRGNyN+rFo0jz7PJ5kMgxxIY=; b=qFi9mMQqmNsId7IXThapFxJzlVFQ05UGmWabgbLH7b9A6qB6cK2NfW3HS+sukoNwBU daO9eEo3Y5XCnKR1aaW2t3ZyUAq5CSdfr4comItyvyHvlGKyfekrkTTx7eKDEg9w1GvZ xLiCxg7z2nwp9xcjrh6wxyHtBElvQSGTfWdq2M+fvcMsha3vOlXI/DUT1EEzxP25Rc4x I8D7Bn+jGAq0hpYDJqqj/vvUt2cEkQRKs1KuJbX59NalW20DgFniMtr/0d0W64lkUVT4 Wd84l9bDjvG4envGvmioxkN0Hy+Lm+hv3dJEgVHwy4j3CFsJ9vBNqPZSWlokpGMYk/5a Sz1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153174; x=1694757974; 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=KTZoQQBHRX8Eh4+DjB2iRGNyN+rFo0jz7PJ5kMgxxIY=; b=em3ylP8dL1FMhmjEFLi29KY1gAKmEgxubNXg6Ysni5dzONaBBT315LZ7I+bJGtducf XBt5gfpWlgUynyf/RA7Ek4NhtI5vwJt/Vnqc3cYRqZ7U51XSeQhT/sMVZr/kbJhN2eU0 G1T6/K1e0rXHuPd+cRHaVqcMqWGube2dlvOPMkQkqtnbPfaa2bcxtxoyeunHK3Vtmhss /pt3itnaIGCcmYgkdxhHy3/DuvSH0+EJ0y0YNpFab3zzyq+x5tmrXmocpInbe+1YAEQK ntm8teL0aGHkVu3m6IZjJ/sBhSuRs4i0AaC5W+whlK+Kxf2YXnf7sSQawaPGbZTfIL2O 2fJg== X-Gm-Message-State: AOJu0YwB/FT0Nr3I5x4ukqlvGAK08qLRq5yZX6OZMA5BC6wWpupWQiMq 8PnVNVUYIGwlIo26AdyuZG9kYySNqXEYb0C+ X-Google-Smtp-Source: AGHT+IFKK9ALwSmCSR5SKHKzs+U1OskQW2iX3aSfqSix7em4UEY11vci0TwU/71wBJOWpzQXTYKAfA== X-Received: by 2002:a17:902:da92:b0:1bb:d280:5e0b with SMTP id j18-20020a170902da9200b001bbd2805e0bmr2138565plx.18.1694153173653; Thu, 07 Sep 2023 23:06:13 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Max Chou , Frank Chang , Richard Henderson , Alistair Francis Subject: [PULL 20/65] crypto: Create sm4_subword Date: Fri, 8 Sep 2023 16:03:46 +1000 Message-ID: <20230908060431.1903919-21-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::632; envelope-from=alistair23@gmail.com; helo=mail-pl1-x632.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: 1694153294757100003 Content-Type: text/plain; charset="utf-8" From: Max Chou Allows sharing of sm4_subword between different targets. Signed-off-by: Max Chou Reviewed-by: Frank Chang Reviewed-by: Richard Henderson Signed-off-by: Max Chou Message-ID: <20230711165917.2629866-14-max.chou@sifive.com> Signed-off-by: Alistair Francis --- include/crypto/sm4.h | 8 ++++++++ target/arm/tcg/crypto_helper.c | 10 ++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/crypto/sm4.h b/include/crypto/sm4.h index 9bd3ebc62e..de8245d8a7 100644 --- a/include/crypto/sm4.h +++ b/include/crypto/sm4.h @@ -3,4 +3,12 @@ =20 extern const uint8_t sm4_sbox[256]; =20 +static inline uint32_t sm4_subword(uint32_t word) +{ + return sm4_sbox[word & 0xff] | + sm4_sbox[(word >> 8) & 0xff] << 8 | + sm4_sbox[(word >> 16) & 0xff] << 16 | + sm4_sbox[(word >> 24) & 0xff] << 24; +} + #endif diff --git a/target/arm/tcg/crypto_helper.c b/target/arm/tcg/crypto_helper.c index fdd70abbfd..7cadd61e12 100644 --- a/target/arm/tcg/crypto_helper.c +++ b/target/arm/tcg/crypto_helper.c @@ -614,10 +614,7 @@ static void do_crypto_sm4e(uint64_t *rd, uint64_t *rn,= uint64_t *rm) CR_ST_WORD(d, (i + 3) % 4) ^ CR_ST_WORD(n, i); =20 - t =3D sm4_sbox[t & 0xff] | - sm4_sbox[(t >> 8) & 0xff] << 8 | - sm4_sbox[(t >> 16) & 0xff] << 16 | - sm4_sbox[(t >> 24) & 0xff] << 24; + t =3D sm4_subword(t); =20 CR_ST_WORD(d, i) ^=3D t ^ rol32(t, 2) ^ rol32(t, 10) ^ rol32(t, 18= ) ^ rol32(t, 24); @@ -651,10 +648,7 @@ static void do_crypto_sm4ekey(uint64_t *rd, uint64_t *= rn, uint64_t *rm) CR_ST_WORD(d, (i + 3) % 4) ^ CR_ST_WORD(m, i); =20 - t =3D sm4_sbox[t & 0xff] | - sm4_sbox[(t >> 8) & 0xff] << 8 | - sm4_sbox[(t >> 16) & 0xff] << 16 | - sm4_sbox[(t >> 24) & 0xff] << 24; + t =3D sm4_subword(t); =20 CR_ST_WORD(d, i) ^=3D t ^ rol32(t, 13) ^ rol32(t, 23); } --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153361; cv=none; d=zohomail.com; s=zohoarc; b=Z3kOXB8KdLpnMiHLFBk6vSGCX/M/iZUGRV9vagN/yGcwJcEkCovJ6AAZd+9BsBvmjury4gMoj2RV+aXLxua1MmMbCe1aHEhJlTuJXSEV83axg3Mtto1gfIpzhBOG+KueC8jtmao0QPYacgbQdmfZwOoCRH6R9tqXiMzRa2xV3Qs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153361; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sW3nOVBepNUyjAGvpAdig0q954l70YYp+9BKZ+7kzlc=; b=im/3zY+wirgAeuxqr5ZucNWtenF9VEs3ADPhVkHqi9Ws8Jfn52H6Rk/p7ANaeyvXQFRminC+9zz/+2CAuTSmQjZ710kwBcLCY923g3NgLku8QNeaSqvahaPnYBCNtn4Ad6qgOz/bWu9Wb6l2+aEhykWmumeH2OtxA1Vn3drXRuM= 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 1694153361466751.1632050639055; Thu, 7 Sep 2023 23:09:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUdY-0001rK-S4; Fri, 08 Sep 2023 02:06:36 -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 1qeUdJ-00014O-GB for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:27 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUdH-0005rd-16 for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:20 -0400 Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-573c62b3cd2so1343215a12.3 for ; Thu, 07 Sep 2023 23:06:18 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.06.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:06:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153177; x=1694757977; 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=sW3nOVBepNUyjAGvpAdig0q954l70YYp+9BKZ+7kzlc=; b=RRpd7eSnAwspvptIILi5AJhRHtlTAXKb5f713qdaiRGrPRRtQ5XnhCwvQdZ/qEvhM+ bKFYhg5CTyViuXUR8iulMoXMOSfrZzlS9pgC5K+xS5Y7wbjCJLLrT779AW8TinIkfQrK xR3HlXuHgmMr8iJ0hg/aN58GLXDzFvj4LfomBOwdJ8EM3DsuKiKY6nrcXm/VajTsakoW 6z9xDZqBtPyhnXjua5+KuyqQToyw0unmqKTLXfkl8xzUuBAiKbyG5DcB07VvYDUMi+tV crhe0jZT3VV++x8DnoixdVLmMXwF5CUeGGzhySiqb071eRB17YInrKh8n/ekXzgXfPMA 73lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153177; x=1694757977; 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=sW3nOVBepNUyjAGvpAdig0q954l70YYp+9BKZ+7kzlc=; b=T8iK7FKrW4E33WWygOzTf6chrY4iezSjttQpEJ+A/Ynny2rlrdUgkB6f3g9QQpy16Q Zx7f26UPShwfaSYyqO96ACWzCe707YtBtxkn0SKoJxRlZFjbBcGhldNsPouOjT14SmNJ qKpLkhRIu5xzIC8qeiQatSEC70eMRR5PR0dmJA6zveM3FtEOgJ0hAS8bg/EqjjSgo+Q3 w8G6oq/O1N2Nxr9/rLhN73id5UA/EEeu9wcfNpbqtdbp5rPbQpuOobzKWkqxqFU/glMo oayZuf74y3OMaisCu8b4DZnHEbgaCrbJF0qMP5BjQRohZ5ENq1CFc7Ff3dZvjMEJtAUj KKYQ== X-Gm-Message-State: AOJu0YxgWE5KEkNj+OQKrbei5ipmdj55Q9DsY7CbBsgvQS38JbKtGrhf 4Ojr0fvKDPv8+SkQsMsuSn6/Ma4bVZnSSkBZ X-Google-Smtp-Source: AGHT+IG65z+vSNOeH0pwEWo+KxLVKebo78CFePpx/1Veomr/5qsmAsaaiDJLeALzvSjTvoR9K5XYZw== X-Received: by 2002:a05:6a20:1442:b0:14c:6397:ac6e with SMTP id a2-20020a056a20144200b0014c6397ac6emr2085516pzi.23.1694153177170; Thu, 07 Sep 2023 23:06:17 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Max Chou , Frank Chang , Alistair Francis Subject: [PULL 21/65] crypto: Add SM4 constant parameter CK Date: Fri, 8 Sep 2023 16:03:47 +1000 Message-ID: <20230908060431.1903919-22-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::535; envelope-from=alistair23@gmail.com; helo=mail-pg1-x535.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: 1694153362216100002 Content-Type: text/plain; charset="utf-8" From: Max Chou Adds sm4_ck constant for use in sm4 cryptography across different targets. Signed-off-by: Max Chou Reviewed-by: Frank Chang Signed-off-by: Max Chou Message-ID: <20230711165917.2629866-15-max.chou@sifive.com> Signed-off-by: Alistair Francis --- include/crypto/sm4.h | 1 + crypto/sm4.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/include/crypto/sm4.h b/include/crypto/sm4.h index de8245d8a7..382b26d922 100644 --- a/include/crypto/sm4.h +++ b/include/crypto/sm4.h @@ -2,6 +2,7 @@ #define QEMU_SM4_H =20 extern const uint8_t sm4_sbox[256]; +extern const uint32_t sm4_ck[32]; =20 static inline uint32_t sm4_subword(uint32_t word) { diff --git a/crypto/sm4.c b/crypto/sm4.c index 9f0cd452c7..2987306cf7 100644 --- a/crypto/sm4.c +++ b/crypto/sm4.c @@ -47,3 +47,13 @@ uint8_t const sm4_sbox[] =3D { 0x79, 0xee, 0x5f, 0x3e, 0xd7, 0xcb, 0x39, 0x48, }; =20 +uint32_t const sm4_ck[] =3D { + 0x00070e15, 0x1c232a31, 0x383f464d, 0x545b6269, + 0x70777e85, 0x8c939aa1, 0xa8afb6bd, 0xc4cbd2d9, + 0xe0e7eef5, 0xfc030a11, 0x181f262d, 0x343b4249, + 0x50575e65, 0x6c737a81, 0x888f969d, 0xa4abb2b9, + 0xc0c7ced5, 0xdce3eaf1, 0xf8ff060d, 0x141b2229, + 0x30373e45, 0x4c535a61, 0x686f767d, 0x848b9299, + 0xa0a7aeb5, 0xbcc3cad1, 0xd8dfe6ed, 0xf4fb0209, + 0x10171e25, 0x2c333a41, 0x484f565d, 0x646b7279 +}; --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153399; cv=none; d=zohomail.com; s=zohoarc; b=RrLaE1O8MDIhsvzIO3DhUxRL1i2eEOKa/dChj2I7i7Joj2CE19I+oPHZvpPnOnTFkOHn94wHyZYG2o+Djy2CTjzLnE6Z9G5v92Na0PBagan6MpR/RL6rK3ves5pxJ60vJastEqLal+dj3i0JOc0a3Wd9/uV81uFUNpHBdnzqCsA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153399; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fh5NRbb/cu0m756EGY6sy0BB/1IMqMKi0hjfM6Xip7Q=; b=jKldgL+eh79H6zae82+ZAZ/BUv/T+XtipNX0Inf0Dl4Us3B/ZkzhT2AsX+VZcxwNxBx1uezOiuxmlFd5PJ/XVPsUhbcR+2XrOrn9+f8fyw0pMOI1YGlBO2gwlJIW6kNQS0eIHbWEak0inxjDl/l8cRnVAwDW/zWQdpDbwo95O+s= 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 1694153399282104.67237736183586; Thu, 7 Sep 2023 23:09:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUdW-0001Wj-9G; Fri, 08 Sep 2023 02:06:34 -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 1qeUdN-00016r-6Z for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:30 -0400 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 1qeUdK-0005x9-Cw for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:24 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1c0d5b16aacso14703055ad.1 for ; Thu, 07 Sep 2023 23:06:22 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.06.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:06:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153181; x=1694757981; 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=fh5NRbb/cu0m756EGY6sy0BB/1IMqMKi0hjfM6Xip7Q=; b=EO2HvySado53YzoBqcpGDa8RxiM2roLlYTFObThnsch0nt5gd+VvBlqxZJGT6KQBGm rBMs2n7TeOjWxEyWSRGsJCqqmdVRTKupjIo4bdH8ZlBFUE1yAmIjxBleFknqjOjBRA6I E6rSazlL3bwB5rAwUjmGWX+MhLdSBv2DFGT6/idZ1r1pB+BI26jSfRXBia/ZivGwy7ck H4OTGzuMX9H0F8c18qs65aQLltqYnTQNzNIsWPCwFFtl8GL5LEXCEuoXndxr1PL+wQFA 4N3wIwnMyvRsf+Ur+Ssvk2yuYHeiu9bj0O2Ul0jvQ5ylNIBK+8rpv9ZShMyEBDlDylLS mUVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153181; x=1694757981; 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=fh5NRbb/cu0m756EGY6sy0BB/1IMqMKi0hjfM6Xip7Q=; b=BkflbsrU00yrcY6rWHsSco+DzLL9CkiowFPWG5vW3Wq+b2Km+2qZJWfMUeVJSnvxvk 71K663e27xG1X7XtsbzlaQQXkirKUzRLAavd7Vo//T1JZ3YQ9FLko2mu8Qi9ZsjqSCr+ ywun/+g8SFAE1wGpTKmLy1ZWpfP33xLEcNtwyorxX6A1BF3oezuxm4LzUtoDHUfPSTrf 9/dAilXkHemV/HN+KA4V/aUG/M2lrYS240YpjDv/1uxrgFPJ0BPppViTbpHVEgFLnTwl JmD//jnnhaDn3C8eVgWxDH9xZGgbljGCeBrVYf/WzSWlkOGxMOmzcTovHQ5PfzFJyg90 DhTg== X-Gm-Message-State: AOJu0YzVqceocgZ561wxcizW2UjfYMK6nEQZHxSk6zAWR96Z5iX/Y8AV gZi3Tqd23OEp7sOxfI1Jqd8Hh0qgh66a09yJ X-Google-Smtp-Source: AGHT+IFvKRQkpxKxpTtN0iIcJNkZfu6Ydv3+wzaqJX1+ryyjBy1mTYwNLg6jJ7/hdL+4th/Rm7BEIg== X-Received: by 2002:a17:903:124f:b0:1bc:6861:d746 with SMTP id u15-20020a170903124f00b001bc6861d746mr1959860plh.58.1694153180654; Thu, 07 Sep 2023 23:06:20 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Max Chou , Frank Chang , Alistair Francis Subject: [PULL 22/65] target/riscv: Add Zvksed ISA extension support Date: Fri, 8 Sep 2023 16:03:48 +1000 Message-ID: <20230908060431.1903919-23-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::62f; envelope-from=alistair23@gmail.com; helo=mail-pl1-x62f.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: 1694153400927100004 Content-Type: text/plain; charset="utf-8" From: Max Chou This commit adds support for the Zvksed vector-crypto extension, which consists of the following instructions: * vsm4k.vi * vsm4r.[vv,vs] Translation functions are defined in `target/riscv/insn_trans/trans_rvvk.c.inc` and helpers are defined in `target/riscv/vcrypto_helper.c`. Signed-off-by: Max Chou Reviewed-by: Frank Chang [lawrence.hunter@codethink.co.uk: Moved SM4 functions from crypto_helper.c to vcrypto_helper.c] [nazar.kazakov@codethink.co.uk: Added alignment checks, refactored code to use macros, and minor style changes] Signed-off-by: Max Chou Message-ID: <20230711165917.2629866-16-max.chou@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/cpu_cfg.h | 1 + target/riscv/helper.h | 4 + target/riscv/insn32.decode | 5 + target/riscv/cpu.c | 5 +- target/riscv/vcrypto_helper.c | 127 +++++++++++++++++++++++ target/riscv/insn_trans/trans_rvvk.c.inc | 43 ++++++++ 6 files changed, 184 insertions(+), 1 deletion(-) diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h index b754ec2344..61f6238756 100644 --- a/target/riscv/cpu_cfg.h +++ b/target/riscv/cpu_cfg.h @@ -91,6 +91,7 @@ struct RISCVCPUConfig { bool ext_zvkned; bool ext_zvknha; bool ext_zvknhb; + bool ext_zvksed; bool ext_zvksh; bool ext_zmmul; bool ext_zvfbfmin; diff --git a/target/riscv/helper.h b/target/riscv/helper.h index ceec97e165..8a63523851 100644 --- a/target/riscv/helper.h +++ b/target/riscv/helper.h @@ -1276,3 +1276,7 @@ DEF_HELPER_5(vsm3c_vi, void, ptr, ptr, i32, env, i32) =20 DEF_HELPER_5(vghsh_vv, void, ptr, ptr, ptr, env, i32) DEF_HELPER_4(vgmul_vv, void, ptr, ptr, env, i32) + +DEF_HELPER_5(vsm4k_vi, void, ptr, ptr, i32, env, i32) +DEF_HELPER_4(vsm4r_vv, void, ptr, ptr, env, i32) +DEF_HELPER_4(vsm4r_vs, void, ptr, ptr, env, i32) diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode index 0fae01c6bb..33597fe2bb 100644 --- a/target/riscv/insn32.decode +++ b/target/riscv/insn32.decode @@ -999,3 +999,8 @@ vsm3c_vi 101011 1 ..... ..... 010 ..... 1110111 @r_v= m_1 # *** Zvkg vector crypto extension *** vghsh_vv 101100 1 ..... ..... 010 ..... 1110111 @r_vm_1 vgmul_vv 101000 1 ..... 10001 010 ..... 1110111 @r2_vm_1 + +# *** Zvksed vector crypto extension *** +vsm4k_vi 100001 1 ..... ..... 010 ..... 1110111 @r_vm_1 +vsm4r_vv 101000 1 ..... 10000 010 ..... 1110111 @r2_vm_1 +vsm4r_vs 101001 1 ..... 10000 010 ..... 1110111 @r2_vm_1 diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 981907c033..dc4b88e625 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -133,6 +133,7 @@ static const struct isa_ext_data isa_edata_arr[] =3D { ISA_EXT_DATA_ENTRY(zvkned, PRIV_VERSION_1_12_0, ext_zvkned), ISA_EXT_DATA_ENTRY(zvknha, PRIV_VERSION_1_12_0, ext_zvknha), ISA_EXT_DATA_ENTRY(zvknhb, PRIV_VERSION_1_12_0, ext_zvknhb), + ISA_EXT_DATA_ENTRY(zvksed, PRIV_VERSION_1_12_0, ext_zvksed), ISA_EXT_DATA_ENTRY(zvksh, PRIV_VERSION_1_12_0, ext_zvksh), ISA_EXT_DATA_ENTRY(zhinx, PRIV_VERSION_1_12_0, ext_zhinx), ISA_EXT_DATA_ENTRY(zhinxmin, PRIV_VERSION_1_12_0, ext_zhinxmin), @@ -1283,7 +1284,8 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu,= Error **errp) * in qemu */ if ((cpu->cfg.ext_zvbb || cpu->cfg.ext_zvkg || cpu->cfg.ext_zvkned || - cpu->cfg.ext_zvknha || cpu->cfg.ext_zvksh) && !cpu->cfg.ext_zve32= f) { + cpu->cfg.ext_zvknha || cpu->cfg.ext_zvksed || cpu->cfg.ext_zvksh)= && + !cpu->cfg.ext_zve32f) { error_setg(errp, "Vector crypto extensions require V or Zve* extensions"= ); return; @@ -1885,6 +1887,7 @@ static Property riscv_cpu_extensions[] =3D { DEFINE_PROP_BOOL("x-zvkned", RISCVCPU, cfg.ext_zvkned, false), DEFINE_PROP_BOOL("x-zvknha", RISCVCPU, cfg.ext_zvknha, false), DEFINE_PROP_BOOL("x-zvknhb", RISCVCPU, cfg.ext_zvknhb, false), + DEFINE_PROP_BOOL("x-zvksed", RISCVCPU, cfg.ext_zvksed, false), DEFINE_PROP_BOOL("x-zvksh", RISCVCPU, cfg.ext_zvksh, false), =20 DEFINE_PROP_END_OF_LIST(), diff --git a/target/riscv/vcrypto_helper.c b/target/riscv/vcrypto_helper.c index a5e2f7fbb0..e2d719b13b 100644 --- a/target/riscv/vcrypto_helper.c +++ b/target/riscv/vcrypto_helper.c @@ -24,6 +24,7 @@ #include "cpu.h" #include "crypto/aes.h" #include "crypto/aes-round.h" +#include "crypto/sm4.h" #include "exec/memop.h" #include "exec/exec-all.h" #include "exec/helper-proto.h" @@ -841,3 +842,129 @@ void HELPER(vgmul_vv)(void *vd_vptr, void *vs2_vptr, = CPURISCVState *env, vext_set_elems_1s(vd, vta, env->vl * 4, total_elems * 4); env->vstart =3D 0; } + +void HELPER(vsm4k_vi)(void *vd, void *vs2, uint32_t uimm5, CPURISCVState *= env, + uint32_t desc) +{ + const uint32_t egs =3D 4; + uint32_t rnd =3D uimm5 & 0x7; + uint32_t group_start =3D env->vstart / egs; + uint32_t group_end =3D env->vl / egs; + uint32_t esz =3D sizeof(uint32_t); + uint32_t total_elems =3D vext_get_total_elems(env, desc, esz); + + for (uint32_t i =3D group_start; i < group_end; ++i) { + uint32_t vstart =3D i * egs; + uint32_t vend =3D (i + 1) * egs; + uint32_t rk[4] =3D {0}; + uint32_t tmp[8] =3D {0}; + + for (uint32_t j =3D vstart; j < vend; ++j) { + rk[j - vstart] =3D *((uint32_t *)vs2 + H4(j)); + } + + for (uint32_t j =3D 0; j < egs; ++j) { + tmp[j] =3D rk[j]; + } + + for (uint32_t j =3D 0; j < egs; ++j) { + uint32_t b, s; + b =3D tmp[j + 1] ^ tmp[j + 2] ^ tmp[j + 3] ^ sm4_ck[rnd * 4 + = j]; + + s =3D sm4_subword(b); + + tmp[j + 4] =3D tmp[j] ^ (s ^ rol32(s, 13) ^ rol32(s, 23)); + } + + for (uint32_t j =3D vstart; j < vend; ++j) { + *((uint32_t *)vd + H4(j)) =3D tmp[egs + (j - vstart)]; + } + } + + env->vstart =3D 0; + /* set tail elements to 1s */ + vext_set_elems_1s(vd, vext_vta(desc), env->vl * esz, total_elems * esz= ); +} + +static void do_sm4_round(uint32_t *rk, uint32_t *buf) +{ + const uint32_t egs =3D 4; + uint32_t s, b; + + for (uint32_t j =3D egs; j < egs * 2; ++j) { + b =3D buf[j - 3] ^ buf[j - 2] ^ buf[j - 1] ^ rk[j - 4]; + + s =3D sm4_subword(b); + + buf[j] =3D buf[j - 4] ^ (s ^ rol32(s, 2) ^ rol32(s, 10) ^ rol32(s,= 18) ^ + rol32(s, 24)); + } +} + +void HELPER(vsm4r_vv)(void *vd, void *vs2, CPURISCVState *env, uint32_t de= sc) +{ + const uint32_t egs =3D 4; + uint32_t group_start =3D env->vstart / egs; + uint32_t group_end =3D env->vl / egs; + uint32_t esz =3D sizeof(uint32_t); + uint32_t total_elems =3D vext_get_total_elems(env, desc, esz); + + for (uint32_t i =3D group_start; i < group_end; ++i) { + uint32_t vstart =3D i * egs; + uint32_t vend =3D (i + 1) * egs; + uint32_t rk[4] =3D {0}; + uint32_t tmp[8] =3D {0}; + + for (uint32_t j =3D vstart; j < vend; ++j) { + rk[j - vstart] =3D *((uint32_t *)vs2 + H4(j)); + } + + for (uint32_t j =3D vstart; j < vend; ++j) { + tmp[j - vstart] =3D *((uint32_t *)vd + H4(j)); + } + + do_sm4_round(rk, tmp); + + for (uint32_t j =3D vstart; j < vend; ++j) { + *((uint32_t *)vd + H4(j)) =3D tmp[egs + (j - vstart)]; + } + } + + env->vstart =3D 0; + /* set tail elements to 1s */ + vext_set_elems_1s(vd, vext_vta(desc), env->vl * esz, total_elems * esz= ); +} + +void HELPER(vsm4r_vs)(void *vd, void *vs2, CPURISCVState *env, uint32_t de= sc) +{ + const uint32_t egs =3D 4; + uint32_t group_start =3D env->vstart / egs; + uint32_t group_end =3D env->vl / egs; + uint32_t esz =3D sizeof(uint32_t); + uint32_t total_elems =3D vext_get_total_elems(env, desc, esz); + + for (uint32_t i =3D group_start; i < group_end; ++i) { + uint32_t vstart =3D i * egs; + uint32_t vend =3D (i + 1) * egs; + uint32_t rk[4] =3D {0}; + uint32_t tmp[8] =3D {0}; + + for (uint32_t j =3D 0; j < egs; ++j) { + rk[j] =3D *((uint32_t *)vs2 + H4(j)); + } + + for (uint32_t j =3D vstart; j < vend; ++j) { + tmp[j - vstart] =3D *((uint32_t *)vd + H4(j)); + } + + do_sm4_round(rk, tmp); + + for (uint32_t j =3D vstart; j < vend; ++j) { + *((uint32_t *)vd + H4(j)) =3D tmp[egs + (j - vstart)]; + } + } + + env->vstart =3D 0; + /* set tail elements to 1s */ + vext_set_elems_1s(vd, vext_vta(desc), env->vl * esz, total_elems * esz= ); +} diff --git a/target/riscv/insn_trans/trans_rvvk.c.inc b/target/riscv/insn_t= rans/trans_rvvk.c.inc index af7cd62e7d..c00c70dfc6 100644 --- a/target/riscv/insn_trans/trans_rvvk.c.inc +++ b/target/riscv/insn_trans/trans_rvvk.c.inc @@ -561,3 +561,46 @@ static bool vghsh_check(DisasContext *s, arg_rmrr *a) } =20 GEN_VV_UNMASKED_TRANS(vghsh_vv, vghsh_check, ZVKG_EGS) + +/* + * Zvksed + */ + +#define ZVKSED_EGS 4 + +static bool zvksed_check(DisasContext *s) +{ + int egw_bytes =3D ZVKSED_EGS << s->sew; + return s->cfg_ptr->ext_zvksed =3D=3D true && + require_rvv(s) && + vext_check_isa_ill(s) && + MAXSZ(s) >=3D egw_bytes && + s->sew =3D=3D MO_32; +} + +static bool vsm4k_vi_check(DisasContext *s, arg_rmrr *a) +{ + return zvksed_check(s) && + require_align(a->rd, s->lmul) && + require_align(a->rs2, s->lmul); +} + +GEN_VI_UNMASKED_TRANS(vsm4k_vi, vsm4k_vi_check, ZVKSED_EGS) + +static bool vsm4r_vv_check(DisasContext *s, arg_rmr *a) +{ + return zvksed_check(s) && + require_align(a->rd, s->lmul) && + require_align(a->rs2, s->lmul); +} + +GEN_V_UNMASKED_TRANS(vsm4r_vv, vsm4r_vv_check, ZVKSED_EGS) + +static bool vsm4r_vs_check(DisasContext *s, arg_rmr *a) +{ + return zvksed_check(s) && + !is_overlapped(a->rd, 1 << MAX(s->lmul, 0), a->rs2, 1) && + require_align(a->rd, s->lmul); +} + +GEN_V_UNMASKED_TRANS(vsm4r_vs, vsm4r_vs_check, ZVKSED_EGS) --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153444; cv=none; d=zohomail.com; s=zohoarc; b=ADH6HEdXSfsInHIbLaZ5G/r/SycPttFftu9O+wt5n11JRj+B6q9gvOd7MfscA1uriYOyt2eI65c3xTnb9CGLhjZFlEtpf/olEq3YXFjArv3AwAezrgySk0ABTl9e6ZCzyII9q47IGpt2pYi3swrrhjzth3eywfaaxDvC9W5Dz4w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153444; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kAP/ARZH03sbdLRgzXuPgyQA9kfPXuXGRtSjy51o5fY=; b=np4zR8p09LL1e9b1yHmYDd7/sR6Ygi+YdylFZnTdwek9W3BAor6iKJECawyoUVUI1phyhOXo/Hm9KN8IHQL8H+IOLFJAv5VR6NRrbXkyg92mwuKTdQaWo3rGu8Wiy2Xq7QYU4FUsUCYAmiSVyEhmWoCq0IwscZYRKPbOZVP/v+k= 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 1694153444406300.10614984759263; Thu, 7 Sep 2023 23:10:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUdr-0003Ka-UO; Fri, 08 Sep 2023 02:06:56 -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 1qeUdR-0001Bu-OI for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:31 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUdN-0005z9-TB for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:27 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1c336f5b1ffso13917475ad.2 for ; Thu, 07 Sep 2023 23:06:25 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.06.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:06:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153184; x=1694757984; 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=kAP/ARZH03sbdLRgzXuPgyQA9kfPXuXGRtSjy51o5fY=; b=lMTNYtAR/BOJzulDZpHgOT2XlP5ODSekxUfLlu5MlYxGcQAkfXpO4LdO4jfWK+JQEt 8wOY6mfZDyHZqJBjXWduRsWtXD5RWRjB02EXnoWYCWc3/Bo5lYIuK26JRs26zq4jGRuL MFW2Ef5VvpkRY90fuenkP8rZ1G/Dn7Put/T5EsaNPODJ/7E0/gQJB5K7c1wgo0ou+l1A 0GdRp1rFCG1QHjDTXYcdVZKr5JPqTrfxcISLnAt7uSXsg5iOFTAkh0x77EGr0AE/PD33 AwbVilbEPqkAZMZfBDz0psWw/t1RXG5450kc/qOj+bxuuS2sWQvgfeSXRGmO8vvO6xpY 8YKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153184; x=1694757984; 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=kAP/ARZH03sbdLRgzXuPgyQA9kfPXuXGRtSjy51o5fY=; b=NoL7rhEXn1P6akfLM+IoQx8MChbxxDcQKdfKwRhOo690mFT99ATAhVf4fvDTltc5np Fs7THwQP03xRFZJeDkB2iUMn76oTQRMh+6OZXDaoUyX0F9S6z1SLL4f5/wj4HBqlFR9I CaTCvwGAX1s3/QMSDH9wxM6/Rkp26He2/DU37DIoEPt1vTMn5ISp8RMhvxqewDqhOfHQ Q4gDwDWN8jnZ/QweKj7mqEGQgqHvFgAQHkCXdGwVWgiv50aLbrwH6VAh+scXuNBj6Zm5 AW90r6QZDLRWKRqCwwuyEhGStQNi7Zsbu512FdWOvKlftChYJfZ8rTxcyzJnTKFgTj2h fUpw== X-Gm-Message-State: AOJu0YwDHADZUdA2iJUJUKHFRMUukndaVnAB59X9fI5ASyssuqL3idNI IdSOoFAJ3uXW7Pm826DaEyQDyZl2FLrxzU8E X-Google-Smtp-Source: AGHT+IFy4ZYa2hVVGCl/VZSia6M/DTQsTL19DMaz401s41fyixpY7Cb9t83vlebMnvzOmgv4nwjNIw== X-Received: by 2002:a17:902:6906:b0:1bb:9c45:130f with SMTP id j6-20020a170902690600b001bb9c45130fmr1624479plk.69.1694153184083; Thu, 07 Sep 2023 23:06:24 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Rob Bradford , Alistair Francis , Atish Patra Subject: [PULL 23/65] target/riscv: Implement WARL behaviour for mcountinhibit/mcounteren Date: Fri, 8 Sep 2023 16:03:49 +1000 Message-ID: <20230908060431.1903919-24-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::636; envelope-from=alistair23@gmail.com; helo=mail-pl1-x636.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: 1694153446110100001 Content-Type: text/plain; charset="utf-8" From: Rob Bradford These are WARL fields - zero out the bits for unavailable counters and special case the TM bit in mcountinhibit which is hardwired to zero. This patch achieves this by modifying the value written so that any use of the field will see the correctly masked bits. Tested by modifying OpenSBI to write max value to these CSRs and upon subsequent read the appropriate number of bits for number of PMUs is enabled and the TM bit is zero in mcountinhibit. Signed-off-by: Rob Bradford Acked-by: Alistair Francis Reviewed-by: Atish Patra Message-ID: <20230802124906.24197-1-rbradford@rivosinc.com> Signed-off-by: Alistair Francis --- target/riscv/csr.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index de31818daa..e4490d5bed 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -1833,8 +1833,11 @@ static RISCVException write_mcountinhibit(CPURISCVSt= ate *env, int csrno, { int cidx; PMUCTRState *counter; + RISCVCPU *cpu =3D env_archcpu(env); =20 - env->mcountinhibit =3D val; + /* WARL register - disable unavailable counters; TM bit is always 0 */ + env->mcountinhibit =3D + val & (cpu->pmu_avail_ctrs | COUNTEREN_CY | COUNTEREN_IR); =20 /* Check if any other counter is also monitoring cycles/instructions */ for (cidx =3D 0; cidx < RV_MAX_MHPMCOUNTERS; cidx++) { @@ -1857,7 +1860,11 @@ static RISCVException read_mcounteren(CPURISCVState = *env, int csrno, static RISCVException write_mcounteren(CPURISCVState *env, int csrno, target_ulong val) { - env->mcounteren =3D val; + RISCVCPU *cpu =3D env_archcpu(env); + + /* WARL register - disable unavailable counters */ + env->mcounteren =3D val & (cpu->pmu_avail_ctrs | COUNTEREN_CY | COUNTE= REN_TM | + COUNTEREN_IR); return RISCV_EXCP_NONE; } =20 --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153216; cv=none; d=zohomail.com; s=zohoarc; b=bx+xEmInFtzJOlHgule6Wrik86q/nefyjFnIlSZENN4GUTe6xkSPq5i1w/5HVYoPJ1Ee3cwghfSlnu5fLziLZa7s+CGWYTX4RbDb8F6E5IYl4aI5vt9Kg08olKUQuu1N1gWr2i8lPuzE4ymHW9TuKU+lJ7IRQzykmz2qV20L8y4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153216; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=g72WiAV5qZ1oQb/83wFsWAvyLD7y1PtWQ+7+Ow3xVqA=; b=RkBNMCSbyrUJx7vXD+TtOyMMSNOH6HgsLefQLPGWR37UoDY8jPFKM+fcWMM0A6mMuJfPibUyjt8/lXZ7Clje4ifS2IvXOAjji1F64I3D5UIe6L/O0SSBvreVRt7eMe3qPbNNEysKFGpD5LThodudB241JMYX5tQViZ6k+dh+BZU= 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 1694153216074903.4574912898266; Thu, 7 Sep 2023 23:06:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUdk-0002U5-RG; Fri, 08 Sep 2023 02:06:48 -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 1qeUdT-0001DC-Sg for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:32 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUdR-0005ze-FW for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:31 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1bdbf10333bso14061975ad.1 for ; Thu, 07 Sep 2023 23:06:29 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.06.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:06:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153187; x=1694757987; 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=g72WiAV5qZ1oQb/83wFsWAvyLD7y1PtWQ+7+Ow3xVqA=; b=HsmRsY0OOFkgdgcIGdMuPHLvwgRA3vRNHBW6jBiNZibsNv0vLDD7sL4zzdj+NbPyLJ p2cVHon/RG3PvuUYWCP6wiTHUAzUiF4AHuaJUtv0Gntf+AB9Uae24RiQggaKd8RxPKjk qhV8T6AOTuHWw6YPXiB4d8NfymqRFm+WywJjuFu/HYArHD7dvJ237DBouuRQLe7Hb6OJ P10QUFZAuKS8nFQV5o5t0Cq8RR9Te3tzBR+W64VCIsDjn6v59OSlW7nLg3deMmsWX7Vc LGBBzw3Fg0fu9DHXlFJAjPFilSJp6dClJFMCbKrLnpoi+O+Ex/T6yUSAWur/YAiuHZwj ePLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153187; x=1694757987; 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=g72WiAV5qZ1oQb/83wFsWAvyLD7y1PtWQ+7+Ow3xVqA=; b=EP/a8NJj+1P9zRA31K3n12cBRm1g+urKPusLXPJmctsdYDqjUXpmTx/+jjMWWdN9Qu 5evIT3gh/FZ1Oujdn7RhI/ayn4Ou650HHxBtND4JYxoUY4TS/a7TqXOIXZOXGU9RwHrV MHS7NaF4QVT0HWFmMVA73PEFaw17XaUULFE+U+GulEY7KLpUUx/8+e5NuoXPj6Xn8MDX nYzFypCzocXYkcmRtNOQs6b1rW6u+KsPwQVLbHPB8lxgNh/j73ePQiZsCUziui204fbZ WZCSJe54wvnbNsomFmQXc8+1x/egIOLIvH8dZJl1daWDiByOJQ4jR58vqaFv9dRQFPxm ICVA== X-Gm-Message-State: AOJu0YzY7YA5Wq2na9ips3/E0ujWPmB7WbrDdJaFUuIqaK/7LxVMQwYe j0FCeU7M91pWR0cRsyT/hILzeh7Fsfg3BdPv X-Google-Smtp-Source: AGHT+IF/souweECsQxcOaPS0vtGcewK+KKc69hUQLmQluF+Z0oRMFC99228JTfOLWjo6QTw/8PFQOw== X-Received: by 2002:a17:902:6b88:b0:1bf:8779:e045 with SMTP id p8-20020a1709026b8800b001bf8779e045mr1328558plk.50.1694153187559; Thu, 07 Sep 2023 23:06:27 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Jason Chien , Frank Chang , Alistair Francis Subject: [PULL 24/65] target/riscv: Add Zihintntl extension ISA string to DTS Date: Fri, 8 Sep 2023 16:03:50 +1000 Message-ID: <20230908060431.1903919-25-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::636; envelope-from=alistair23@gmail.com; helo=mail-pl1-x636.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: 1694153216969100001 Content-Type: text/plain; charset="utf-8" From: Jason Chien RVA23 Profiles states: The RVA23 profiles are intended to be used for 64-bit application processors that will run rich OS stacks from standard binary OS distributions and with a substantial number of third-party binary user applications that will be supported over a considerable length of time in the field. The chapter 4 of the unprivileged spec introduces the Zihintntl extension and Zihintntl is a mandatory extension presented in RVA23 Profiles, whose purpose is to enable application and operating system portability across different implementations. Thus the DTS should contain the Zihintntl ISA string in order to pass to software. The unprivileged spec states: Like any HINTs, these instructions may be freely ignored. Hence, although they are described in terms of cache-based memory hierarchies, they do not mandate the provision of caches. These instructions are encoded with non-used opcode, e.g. ADD x0, x0, x2, which QEMU already supports, and QEMU does not emulate cache. Therefore these instructions can be considered as a no-op, and we only need to add a new property for the Zihintntl extension. Reviewed-by: Frank Chang Reviewed-by: Alistair Francis Signed-off-by: Jason Chien Message-ID: <20230726074049.19505-2-jason.chien@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/cpu_cfg.h | 1 + target/riscv/cpu.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h index 61f6238756..0e6a0f245c 100644 --- a/target/riscv/cpu_cfg.h +++ b/target/riscv/cpu_cfg.h @@ -66,6 +66,7 @@ struct RISCVCPUConfig { bool ext_icbom; bool ext_icboz; bool ext_zicond; + bool ext_zihintntl; bool ext_zihintpause; bool ext_smstateen; bool ext_sstc; diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index dc4b88e625..fae1c92c5c 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -87,6 +87,7 @@ static const struct isa_ext_data isa_edata_arr[] =3D { ISA_EXT_DATA_ENTRY(zicond, PRIV_VERSION_1_12_0, ext_zicond), ISA_EXT_DATA_ENTRY(zicsr, PRIV_VERSION_1_10_0, ext_icsr), ISA_EXT_DATA_ENTRY(zifencei, PRIV_VERSION_1_10_0, ext_ifencei), + ISA_EXT_DATA_ENTRY(zihintntl, PRIV_VERSION_1_10_0, ext_zihintntl), ISA_EXT_DATA_ENTRY(zihintpause, PRIV_VERSION_1_10_0, ext_zihintpause), ISA_EXT_DATA_ENTRY(zmmul, PRIV_VERSION_1_12_0, ext_zmmul), ISA_EXT_DATA_ENTRY(zawrs, PRIV_VERSION_1_12_0, ext_zawrs), @@ -1790,6 +1791,7 @@ static Property riscv_cpu_extensions[] =3D { DEFINE_PROP_BOOL("sscofpmf", RISCVCPU, cfg.ext_sscofpmf, false), DEFINE_PROP_BOOL("Zifencei", RISCVCPU, cfg.ext_ifencei, true), DEFINE_PROP_BOOL("Zicsr", RISCVCPU, cfg.ext_icsr, true), + DEFINE_PROP_BOOL("Zihintntl", RISCVCPU, cfg.ext_zihintntl, true), DEFINE_PROP_BOOL("Zihintpause", RISCVCPU, cfg.ext_zihintpause, true), DEFINE_PROP_BOOL("Zawrs", RISCVCPU, cfg.ext_zawrs, true), DEFINE_PROP_BOOL("Zfa", RISCVCPU, cfg.ext_zfa, true), --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153222; cv=none; d=zohomail.com; s=zohoarc; b=Md0lVvLao02BvqAnQlKqi8YDCRkDsfg8NRE3kGtwwqtgFiTpSMskti56OJSZuOT5vsMZyVpvvv1KunDRzp4W2AG6CYZ4zwjDtQVFgAyVjmEz7GS9n1mh8YZ9qDhRUgBSSOQxKz2ylqZmIluPm1XFq2jJZz17NuIedb5GnVBk04I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153222; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9c267mtx4FDo5BCCDJhdU8KtpdHS7OWZ9xPSR5tVl8Q=; b=cd8Hm9vyReJWSPJTWQzyl1+kP73y8xHj+OLW44FsVHs8z9na1m6qqO4Yb8GbcXptaDxCRJRMBH+b88LCYNbZV8EGt/URcavJIy8UiUE3aMe1R8FkMrSF5wjvBZ4VFTtxpfs7nSPzTsCegZ5bVkuQhya2iekD71HWC7gFL36/jtQ= 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 1694153222808369.6911083020168; Thu, 7 Sep 2023 23:07:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUdb-00022J-GQ; Fri, 08 Sep 2023 02:06:41 -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 1qeUdX-0001nj-Ti for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:35 -0400 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 1qeUdV-00064D-Io for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:35 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1c34c9cc9b9so13555565ad.3 for ; Thu, 07 Sep 2023 23:06:33 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.06.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:06:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153192; x=1694757992; 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=9c267mtx4FDo5BCCDJhdU8KtpdHS7OWZ9xPSR5tVl8Q=; b=ruBju3HIY8oRewh4HUqX7iRJoY+N/2j8GG7QCXSYxFwwoQqgdLRmuDVzLT1nQFfTj0 ANxjiehil2iUDswVDLNrvxiWjGBzP773pNoztzgtFtqIgyA1OUo0G2fCgZcJeXn1i3mU Rz7qYI8DN/V25Q77b9NTVlLH6ZZSqbvM9aKgsyK5cT/Hn/iFCztPVJyry3u37hzR23VT fmJDk/WUZKdsD9cA74nWBHgEE7qL09yPP1aC7Jvg82SszWv+mee2sjMh9p23yGGw1Yh+ SCI3TYWJZjD+238jQzoSbuRnX+EvohZKd3YBFatUM/WU6BiMvXBR1DdX4STyWBXEmxVa ZzZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153192; x=1694757992; 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=9c267mtx4FDo5BCCDJhdU8KtpdHS7OWZ9xPSR5tVl8Q=; b=xMGVA4r6XydqkxRSJ+GyTBwg62jxm+ho/t4mCPk54wzXiYiBrgYwtqe0znfDTTPfQ6 18Eaulm0tL6X+x2i+ce8H3ypujMKQ2m+QDjmKqjcB/3+JrvJ5xLoWsP5ottSRsW//Anr XjKL7VdBP5dgfH5BKfTiWRAdrl2DksxpDyujD95Io5zNAaOYnnn9QK9z2BvIuo1Gxey/ ewbR12X5U5T8a5BhAIuq/3xP+rNOD+S3tLXXR/wgZoH+ytLXzOvcxYzXujXevKUI0xFa duCEmj03TNZIhVe6mmKTqwi2VM2/6gGKNUlKJrl+mAo4LzTarqgkSoGYQXTmJUKevAzx iCvQ== X-Gm-Message-State: AOJu0YwS5whdYlXot+j4NydHn392HPgR6isX1PP8ulm1cH7MlaztUloE BFcK8Dqz6oUYP2J8BPxBLoN0Lfy+mPWCJtY4 X-Google-Smtp-Source: AGHT+IHtGw4ewKpEN4yMUUR+IpE+DFsfVQ7cLEKcgDDDskwT9zDzZIs1GlnlHfqLbxqaZC+OjinHPQ== X-Received: by 2002:a17:902:b490:b0:1c2:eac:b99 with SMTP id y16-20020a170902b49000b001c20eac0b99mr1672728plr.40.1694153191889; Thu, 07 Sep 2023 23:06:31 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, LIU Zhiwei , Daniel Henrique Barboza , Weiwei Li , Alistair Francis Subject: [PULL 25/65] target/riscv: Fix zfa fleq.d and fltq.d Date: Fri, 8 Sep 2023 16:03:51 +1000 Message-ID: <20230908060431.1903919-26-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::629; envelope-from=alistair23@gmail.com; helo=mail-pl1-x629.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: 1694153224457100003 Content-Type: text/plain; charset="utf-8" From: LIU Zhiwei Commit a47842d ("riscv: Add support for the Zfa extension") implemented the= zfa extension. However, it has some typos for fleq.d and fltq.d. Both of them misused the = fltq.s helper function. Fixes: a47842d ("riscv: Add support for the Zfa extension") Signed-off-by: LIU Zhiwei Reviewed-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Message-ID: <20230728003906.768-1-zhiwei_liu@linux.alibaba.com> Signed-off-by: Alistair Francis --- target/riscv/insn_trans/trans_rvzfa.c.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/riscv/insn_trans/trans_rvzfa.c.inc b/target/riscv/insn_= trans/trans_rvzfa.c.inc index 2c715af3e5..0fdd2698f6 100644 --- a/target/riscv/insn_trans/trans_rvzfa.c.inc +++ b/target/riscv/insn_trans/trans_rvzfa.c.inc @@ -470,7 +470,7 @@ bool trans_fleq_d(DisasContext *ctx, arg_fleq_d *a) TCGv_i64 src1 =3D get_fpr_hs(ctx, a->rs1); TCGv_i64 src2 =3D get_fpr_hs(ctx, a->rs2); =20 - gen_helper_fltq_s(dest, cpu_env, src1, src2); + gen_helper_fleq_d(dest, cpu_env, src1, src2); gen_set_gpr(ctx, a->rd, dest); return true; } @@ -485,7 +485,7 @@ bool trans_fltq_d(DisasContext *ctx, arg_fltq_d *a) TCGv_i64 src1 =3D get_fpr_hs(ctx, a->rs1); TCGv_i64 src2 =3D get_fpr_hs(ctx, a->rs2); =20 - gen_helper_fltq_s(dest, cpu_env, src1, src2); + gen_helper_fltq_d(dest, cpu_env, src1, src2); gen_set_gpr(ctx, a->rd, dest); return true; } --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153686; cv=none; d=zohomail.com; s=zohoarc; b=ToTEyxfxXbnVOhphOaMfOqpKEDnpRMWv3ZYsyu9sLj+e3osGYjL1nPqz7+Hd0bAk9WeU+2tnK47rfhFUtdoQB9gKKzi1ebjqN0liEnMQf3UxM+z6SgB555/Q3zT7dTcTv6isizW7ob8SGTfKAiJdoORMtNsCpEYMMFn1m/GLmoo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153686; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RbNY4sxLzfh+2ICvNwghFUDrAY++mutb7jKSlH2h1II=; b=InzVG11EtRE/r/TtQ6f+D7Rr5K+l7xeXf1R8nA4w8UcAvEdf4AAfRIfCRmSmBljB8P0kqSaaVwHJllKlHm4Xhp+90HXLLLZlKnTz1kcVU4AZqDOWAl44UgUFqbMRLT0suA3b0+ZVyfdmJ9GXkRvNcRl1MobDXOF6axaCMvMN2nA= 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 1694153686654842.5707889051704; Thu, 7 Sep 2023 23:14:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUdp-0002tr-0b; Fri, 08 Sep 2023 02:06:53 -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 1qeUdb-0002Pu-N6 for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:41 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUdY-0006Bp-R3 for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:38 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-68c576d35feso1614732b3a.2 for ; Thu, 07 Sep 2023 23:06:36 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.06.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:06:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153195; x=1694757995; 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=RbNY4sxLzfh+2ICvNwghFUDrAY++mutb7jKSlH2h1II=; b=pJE2ks3IENkjKHUJmLnxx6qfPHsXc7sMXNvFEbbIwJdiBkCGii6s5ItVb/D+w450VL r5fkEF4nE5i2hAAlwwwpjJ5LrZ/ad2O4Z9Z80egq1OsaMEaJ9xPcKh+9LA6l7ZjBl24d frwMkSZ13G61C9ZqtiDa++lRFKOrxMewN11eH85Gd+9o+pV3+Pnp0AMb3/EdtvkqTgmz onmTUfnYbgidIWHLlruZ3HiKjW8w6pzL1TSFE7Y+Zb6sfCTc3OhprcmqcRR3BDhiLvxw xfEuJ619bsW83RgBgzwsPBf4LZN36LuKkPetUhE5dRIRicxvtZPTbB6u4KQDizOpNS9s 5CEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153195; x=1694757995; 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=RbNY4sxLzfh+2ICvNwghFUDrAY++mutb7jKSlH2h1II=; b=dlGSu30jMu3IsvBQULPDZVCWa/K++5K3sXvpl7l01BrLcrqTnA3EiZaaA094OAUQzR CKUpWBivq0METLuklpCQ8GJIF3r1oigwgUfRNabf7iVMeLcLImMb1BfnrXU9djkzvpvL syPQYqelQrh+XjftbVavt42PKhJ5J7MP5iIzZ2vDcZCE03B0qAweJYOgbBha91wotb5N TSWnpe6KTxKFtIypnXYbC2zrsE4tat0foZjH6GE2T8w2YNGBHoq42gZITmsIbFlBwXKN hpFi+NwsnWK/cdSnPpH0Qu5Srlgy2IxDZLd65Q7Zx+nsO6hqZK6JUThiGQvhSpke8ZKe bodQ== X-Gm-Message-State: AOJu0YyZc/JGdkBoIOvI8mJrm4AsDSNKmKSztubKmT8zyLcV7/eqktPR c8AzOmOGW5xj1IBTVX3EWgPpLRccdpoLIak7 X-Google-Smtp-Source: AGHT+IERqs+8agxeZ55AM+KOrnO1cUwl8XEe/MkOF53J8WwDfNxGAQOMGLOGIdYKJjHhL4Wz5t9MhQ== X-Received: by 2002:a05:6a20:431a:b0:14c:c986:d105 with SMTP id h26-20020a056a20431a00b0014cc986d105mr1970735pzk.45.1694153195095; Thu, 07 Sep 2023 23:06:35 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Jason Chien , Alistair Francis Subject: [PULL 26/65] hw/intc: Fix upper/lower mtime write calculation Date: Fri, 8 Sep 2023 16:03:52 +1000 Message-ID: <20230908060431.1903919-27-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::436; envelope-from=alistair23@gmail.com; helo=mail-pf1-x436.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: 1694153688908100003 Content-Type: text/plain; charset="utf-8" From: Jason Chien When writing the upper mtime, we should keep the original lower mtime whose value is given by cpu_riscv_read_rtc() instead of cpu_riscv_read_rtc_raw(). The same logic applies to writes to lower mtime. Signed-off-by: Jason Chien Reviewed-by: Alistair Francis Message-ID: <20230728082502.26439-1-jason.chien@sifive.com> Signed-off-by: Alistair Francis --- hw/intc/riscv_aclint.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/intc/riscv_aclint.c b/hw/intc/riscv_aclint.c index b466a6abaf..bf77e29a70 100644 --- a/hw/intc/riscv_aclint.c +++ b/hw/intc/riscv_aclint.c @@ -208,11 +208,12 @@ static void riscv_aclint_mtimer_write(void *opaque, h= waddr addr, return; } else if (addr =3D=3D mtimer->time_base || addr =3D=3D mtimer->time_b= ase + 4) { uint64_t rtc_r =3D cpu_riscv_read_rtc_raw(mtimer->timebase_freq); + uint64_t rtc =3D cpu_riscv_read_rtc(mtimer); =20 if (addr =3D=3D mtimer->time_base) { if (size =3D=3D 4) { /* time_lo for RV32/RV64 */ - mtimer->time_delta =3D ((rtc_r & ~0xFFFFFFFFULL) | value) = - rtc_r; + mtimer->time_delta =3D ((rtc & ~0xFFFFFFFFULL) | value) - = rtc_r; } else { /* time for RV64 */ mtimer->time_delta =3D value - rtc_r; @@ -220,7 +221,7 @@ static void riscv_aclint_mtimer_write(void *opaque, hwa= ddr addr, } else { if (size =3D=3D 4) { /* time_hi for RV32/RV64 */ - mtimer->time_delta =3D (value << 32 | (rtc_r & 0xFFFFFFFF)= ) - rtc_r; + mtimer->time_delta =3D (value << 32 | (rtc & 0xFFFFFFFF)) = - rtc_r; } else { qemu_log_mask(LOG_GUEST_ERROR, "aclint-mtimer: invalid time_hi write: %08x", --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153289; cv=none; d=zohomail.com; s=zohoarc; b=MmF3ETF+OECMcfNDjsYuIWkmjooeUTdPZLGaehQsiSV7nUOZg7KJuI6dpGouTAtcKuCaH4HmTOdGR77IY/OmK9aaxfolaUkrFVrYFyvqpHwkyDvytZVRPtn8vzWKybTGbvDdwPbkB7VMDnLYyKH6hId1F949dERVtOdsJtU338g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153289; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ccGf/43x5nzKqeckplvIj3QC6H4I6RRe2CJqwTH4Zqo=; b=c5cdJWuTb5dCTuKe4BDmxzQ+Gmh+zIn8aT/1OLCm+Ts3Z7fbabCOPfsVTF8ASmJwfoJX6d3zKlXlpYCGtOVocGspkuM5L33rD7fMc3hDTVXzXqwXr8Me7B7/XlWfj/ibwlbvxxdMXQdmGh51S9Ireym0MlH1u1IWGebwYqs+ORU= 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 1694153289855660.7505825765227; Thu, 7 Sep 2023 23:08:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUdr-0003KV-U9; Fri, 08 Sep 2023 02:06:56 -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 1qeUdf-0002Qk-Au for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:45 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUdc-0006Hj-32 for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:42 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1c0d0bf18d7so13796715ad.0 for ; Thu, 07 Sep 2023 23:06:39 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.06.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:06:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153198; x=1694757998; 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=ccGf/43x5nzKqeckplvIj3QC6H4I6RRe2CJqwTH4Zqo=; b=KP2DQkLvAdtRvox0N6SOB9NvQU6VZ06L6txxxgCN0GiWFnuwGGdgMsz5ONCOnxqtgm 9EXt4iboWYpfYnFCu7/Ns/qvP7HLM1IhEMXDmy1lS9/GVxxbingflvyO8TBgQ+es+9gi JEXyep6DF8zi23syx4HZuNIODTML9/Dw2AwWmBBPZYUkRV1EdbFldcXXo6VLXTNKw8ru HAm9xjLJWA8+ywKuPMVMMNwqtmaX9ak3kg90Q8VukVXR8mvJz2J/BNbDaw4RYS3bZd4q W4yAKTnUQhs/eXrwAjTYNuWdYbaNxH6qhpakm3WHXpJYKkygi5WOTnGCntSk3ci0XXvs bNQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153198; x=1694757998; 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=ccGf/43x5nzKqeckplvIj3QC6H4I6RRe2CJqwTH4Zqo=; b=eaOiqMqy1smX2/SXYMUogSn2MxODljjFcAmxfTcS3d8Y22pX19KNR49dw7QzAGXMNY dYZrDPh21v/8cdHohbIxpG5GlfN8YVybnjUPX2xiHUH2PNCu51SBn+Qf0VUOeiMJ8PJt WXeS0OfTXPqkNCUZiSHaXU714mbJPwkqYhvrRUVddx5TQT3GPEWUuxTQ2K+cssbY3ffV +zhvi85RIMJC3xtTDOAPfutIASdO5DtJAKcNaQH98nY72MmBv7ljXKMqE/W49pZ0+Ji8 ve8kjDu4/8ydjq0KjrB8mrwPZLinkCNhSIxznySNdOmDy7sj+uxep2ACSY7PCLjEvTiN giYw== X-Gm-Message-State: AOJu0YxDd5HCoPaL+nkZv5DMJJLP8wtcaaYy3QJxHNYeJAX+nfXBdexP 6FWvknC0FnmQyChCvuZjLBYFwMILKITLRZZe X-Google-Smtp-Source: AGHT+IFUytjo9ReK8iqU2qz3U3ENlv9Ru4HkL+It8a5Vl11QCIaR2bKlk6mvVquRGjZAgu8vQnr1iw== X-Received: by 2002:a17:902:ec88:b0:1bd:f314:7896 with SMTP id x8-20020a170902ec8800b001bdf3147896mr1711721plg.25.1694153198266; Thu, 07 Sep 2023 23:06:38 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Jason Chien , Alistair Francis Subject: [PULL 27/65] hw/intc: Make rtc variable names consistent Date: Fri, 8 Sep 2023 16:03:53 +1000 Message-ID: <20230908060431.1903919-28-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::62a; envelope-from=alistair23@gmail.com; helo=mail-pl1-x62a.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: 1694153290681100003 Content-Type: text/plain; charset="utf-8" From: Jason Chien The variables whose values are given by cpu_riscv_read_rtc() should be named "rtc". The variables whose value are given by cpu_riscv_read_rtc_raw() should be named "rtc_r". Signed-off-by: Jason Chien Reviewed-by: Alistair Francis Message-ID: <20230728082502.26439-2-jason.chien@sifive.com> Signed-off-by: Alistair Francis --- hw/intc/riscv_aclint.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/intc/riscv_aclint.c b/hw/intc/riscv_aclint.c index bf77e29a70..25cf7a5d9d 100644 --- a/hw/intc/riscv_aclint.c +++ b/hw/intc/riscv_aclint.c @@ -64,13 +64,13 @@ static void riscv_aclint_mtimer_write_timecmp(RISCVAcli= ntMTimerState *mtimer, uint64_t next; uint64_t diff; =20 - uint64_t rtc_r =3D cpu_riscv_read_rtc(mtimer); + uint64_t rtc =3D cpu_riscv_read_rtc(mtimer); =20 /* Compute the relative hartid w.r.t the socket */ hartid =3D hartid - mtimer->hartid_base; =20 mtimer->timecmp[hartid] =3D value; - if (mtimer->timecmp[hartid] <=3D rtc_r) { + if (mtimer->timecmp[hartid] <=3D rtc) { /* * If we're setting an MTIMECMP value in the "past", * immediately raise the timer interrupt @@ -81,7 +81,7 @@ static void riscv_aclint_mtimer_write_timecmp(RISCVAclint= MTimerState *mtimer, =20 /* otherwise, set up the future timer interrupt */ qemu_irq_lower(mtimer->timer_irqs[hartid]); - diff =3D mtimer->timecmp[hartid] - rtc_r; + diff =3D mtimer->timecmp[hartid] - rtc; /* back to ns (note args switched in muldiv64) */ uint64_t ns_diff =3D muldiv64(diff, NANOSECONDS_PER_SECOND, timebase_f= req); =20 --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153228; cv=none; d=zohomail.com; s=zohoarc; b=BizkCkFQGEZfo75zTP3hM1ytDuSRI90GRfywy6X7k97KawHiwfJG/7qUCuRmLvIg08fooSDNtzI1OfSjYOYXOS1h2FRAS3k2hp7aOarkNeV56ENBaG/pB5xu7ig3GglTATB/POLJCLMKNvD7r5RgV7xQPjc0/hzYL+84F7nSihA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153228; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=s9QHVi3wOzOBTnchANYcU4Sl/KIRcnvifC0QwRT4WCQ=; b=SavhI4UlGkww2ssvnUOjYVmSZm574J3S+5bMdd92ahg1wwbGdCsTD++5mD/5ayiKjMmzc8YhSSR5xjJWOxxFgJ46uBK3cZADUVubNXgaULcBPvt8vTo+c9dygdipGzECrejwpsUQ5oBsxpPbXdU9b+ClV3XgyhDFF8I5RHmtYxY= 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 1694153228963417.29506286353535; Thu, 7 Sep 2023 23:07:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUdq-00038O-F6; Fri, 08 Sep 2023 02:06:54 -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 1qeUdk-0002ZJ-EM for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:48 -0400 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 1qeUdh-0006NV-9S for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:48 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1bdc19b782aso13621325ad.0 for ; Thu, 07 Sep 2023 23:06:43 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.06.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:06:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153202; x=1694758002; 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=s9QHVi3wOzOBTnchANYcU4Sl/KIRcnvifC0QwRT4WCQ=; b=n8iikH3MUxDnka35KkksUOHen2onJ+jMlPXLvgQy3Vghv98VpEnOHIrxazW9pljhvR OE8CL6P/5bwl0rkuk7lE7DUXANOjtz9TESKOlF6qmRFxEi5LrHGiK+XIIA1vw2el8U3M XZy6nqoyMrxcLCDbXDpNi5EPWmGI9sGmCKW7kY/8q/CJg1G8+Mzwa8Psm/PTC/mF/3zO cib8XKwt8xYy5/vnQRpu5N8zMjqF0+eFyE6ELp4wvF/QO7YglhMKcVNN8sQFBmTIuOP5 6OJ6VhHrpARCe+m0R1jBzM4ZKDvupcUz9TIogchjkawcCfb+B2oNXf/58mdwaBR7ZlhA SGdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153202; x=1694758002; 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=s9QHVi3wOzOBTnchANYcU4Sl/KIRcnvifC0QwRT4WCQ=; b=TLwzbmNw4N1LqXuy6yPPDgu0myCRop6YABqNqS2eqlek01MsKB2eLXDuAdB+ErqOZL gm25b/Y0IfmpI28pWyotthJab5pzmiT5xjRTNvI33T8RafCLbCWpU5E9BrAUJcDmbqT4 vIBCN6wUihnq//AamF5UNTLCn1bH8SUmvJu6zpsIDtQgY6o9BPzwG2a2hCPzfKM3ouDd Xa0+I5Th2m8D6dmS9ZdVhUY+nBFDeSbleQYqwSUzCwX2C1BmG5HXtZ1msiSRJubreYS/ k14YC1g8KiPmolezCZRiwvKdeTyQLOjsRA3fURCub9w15Me1ErudWcaknhUHtCoYxrQB J3ig== X-Gm-Message-State: AOJu0YwpfNRer4gEBmmxlirzQHfTZBevJGx8rghs+xv3A6CRxCliuesD VWvxcDAMCAT72WwuJN2yg8KP2R7+90w6o1w6 X-Google-Smtp-Source: AGHT+IHkJ9p1LIaZ/5Wee7giomJGnmbK1xtFrIJ2neqEWrvqg9guOsGAb2hDBNmRD2MDTD50tHUS+w== X-Received: by 2002:a17:902:c1c4:b0:1bc:2c79:c6b5 with SMTP id c4-20020a170902c1c400b001bc2c79c6b5mr1396100plc.4.1694153202129; Thu, 07 Sep 2023 23:06:42 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, LIU Zhiwei , Richard Henderson , Daniel Henrique Barboza , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Alistair Francis Subject: [PULL 28/65] linux-user/riscv: Use abi type for target_ucontext Date: Fri, 8 Sep 2023 16:03:54 +1000 Message-ID: <20230908060431.1903919-29-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=alistair23@gmail.com; helo=mail-pl1-x62f.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: 1694153229336100001 From: LIU Zhiwei We should not use types dependend on host arch for target_ucontext. This bug is found when run rv32 applications. Signed-off-by: LIU Zhiwei Reviewed-by: Richard Henderson Reviewed-by: Daniel Henrique Barboza Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-ID: <20230811055438.1945-1-zhiwei_liu@linux.alibaba.com> Signed-off-by: Alistair Francis --- linux-user/riscv/signal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux-user/riscv/signal.c b/linux-user/riscv/signal.c index eaa168199a..f989f7f51f 100644 --- a/linux-user/riscv/signal.c +++ b/linux-user/riscv/signal.c @@ -38,8 +38,8 @@ struct target_sigcontext { }; /* cf. riscv-linux:arch/riscv/include/uapi/asm/ptrace.h */ =20 struct target_ucontext { - unsigned long uc_flags; - struct target_ucontext *uc_link; + abi_ulong uc_flags; + abi_ptr uc_link; target_stack_t uc_stack; target_sigset_t uc_sigmask; uint8_t __unused[1024 / 8 - sizeof(target_sigset_t)]; --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153231; cv=none; d=zohomail.com; s=zohoarc; b=Oe8SbNNAVdQmxO+8apVKw+IEBFcTZSNZ5bFQncZWZxWSAHaqraXvdDF768yQgTPfAD/kBjdmcdkRUFcxH1wzCvffS+fL2KK6GKqpXfRD4eBniuW9naLflLytzHlg3s8PgnoDFvJRJeCyyka2VCiH58igdfMhotKB6MsjjYt/9vk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153231; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Pz8/wmaBR1oYMEEeH5IrAwvIqyX22QrTA0wQ+EdAqQQ=; b=SSw/bR94FB7HHbnClb+WhyyodypuAiSPYAQ8SgABN8qKgOLvpOCJeldrrtKvchITZloci7uosmf/CNgOl3Nqt056wn+4d/pYE2gtvcxKpHegMVx2tvd9s+XS4F4rfa7CkxOFk1gXCxWKA4OuXDkW3fQ8UUxHfM7nICQD/PkcLgc= 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 1694153231037519.5483609269754; Thu, 7 Sep 2023 23:07:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUdt-0003Yz-6d; Fri, 08 Sep 2023 02:06:57 -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 1qeUdo-0002pv-AZ for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:52 -0400 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 1qeUdk-0006Po-75 for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:52 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1c0d5b16aacso14705375ad.1 for ; Thu, 07 Sep 2023 23:06:47 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.06.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:06:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153206; x=1694758006; 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=Pz8/wmaBR1oYMEEeH5IrAwvIqyX22QrTA0wQ+EdAqQQ=; b=A+O/JJ6ExOhTZN7g3beK8Gpj8E9mwUwvrVPgdORQ35ChGMG48WXyLtdvvFBl2+lhhP 4awX8Vw13flNImnWWi/U8ZjbJ7vnH3XopzYPUN5MmYuEPs1D9nMvFinDBN5ZHEMoPKqb SetUDrp2D00+GRUz6xQgpKl7bPCHXv1Twf6c7ljB3cciSV6GuHRlX3TLQ+Sg+Pcnr2hC ZwCtak0QCIQy7sh6PHIEB7dv6rKVXb9id9560F0tosZank6W2V20YN4QESgQsOcYg7Jd WOgLrCymr+4MmTYLD5ZkF2YqqfmE0xdSxwag7sR3BwS3N2XKAsZmp10qzjh6Ashgldfu dCDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153206; x=1694758006; 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=Pz8/wmaBR1oYMEEeH5IrAwvIqyX22QrTA0wQ+EdAqQQ=; b=bREkuhSMfiuromtbJ58UX8o5ncGXfVTuTKWUZ1b9KhH+ovwk+u4ExX3HTzkH8rZiyE qp0agRnv09C16aP7THUlAAAAIjB4xCXdbw928OedLS2LEqzjenaG56hB2JklMlFClic/ hoYzw3w21xQ1gBlhim6nKnWvmRK5ixCgx72aznQ4eHpfeYzaTtde/TsgXaQGwq2ifc3e oShTqqrhgS9iE7Z1A3iu+coOai0ogH/lLNr67M5MFVzZi1G2LCeaDv8C/PDvX/qpCDlN +WQ6wc0HDT92Xxlg1ScZKWU8Ys+SqQ8cVNvb9NEQAZVSrEp/rytSUygVqX4RGGMSKLEu RefA== X-Gm-Message-State: AOJu0Yyn/IobvGYocrE2j4XObUDB77lk/k2qzgzOSalBeJ3bTdMKwIYe 46jYthijPOVjTZWwi2UvS5dAh/muK8W745Vh X-Google-Smtp-Source: AGHT+IEyROBHcntExbONOey4xN4Q0lJJGo1qvtPzxDm8fhRqX7fg7THWwYFB1w+pGHdy1EYT19EwJg== X-Received: by 2002:a17:903:1c5:b0:1b8:865d:6e1d with SMTP id e5-20020a17090301c500b001b8865d6e1dmr1649070plh.51.1694153206362; Thu, 07 Sep 2023 23:06:46 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Yong-Xuan Wang , Jim Shu , Daniel Henrique Barboza , Andrew Jones , Alistair Francis Subject: [PULL 29/65] target/riscv: support the AIA device emulation with KVM enabled Date: Fri, 8 Sep 2023 16:03:55 +1000 Message-ID: <20230908060431.1903919-30-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::633; envelope-from=alistair23@gmail.com; helo=mail-pl1-x633.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: 1694153231519100006 Content-Type: text/plain; charset="utf-8" From: Yong-Xuan Wang In this patch, we create the APLIC and IMSIC FDT helper functions and remove M mode AIA devices when using KVM acceleration. Signed-off-by: Yong-Xuan Wang Reviewed-by: Jim Shu Reviewed-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Message-ID: <20230727102439.22554-2-yongxuan.wang@sifive.com> Signed-off-by: Alistair Francis --- hw/riscv/virt.c | 290 +++++++++++++++++++++++------------------------- 1 file changed, 137 insertions(+), 153 deletions(-) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 99c4e6314b..693b2df8df 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -516,79 +516,28 @@ static uint32_t imsic_num_bits(uint32_t count) return ret; } =20 -static void create_fdt_imsic(RISCVVirtState *s, const MemMapEntry *memmap, - uint32_t *phandle, uint32_t *intc_phandles, - uint32_t *msi_m_phandle, uint32_t *msi_s_phan= dle) +static void create_fdt_one_imsic(RISCVVirtState *s, hwaddr base_addr, + uint32_t *intc_phandles, uint32_t msi_pha= ndle, + bool m_mode, uint32_t imsic_guest_bits) { int cpu, socket; char *imsic_name; MachineState *ms =3D MACHINE(s); int socket_count =3D riscv_socket_count(ms); - uint32_t imsic_max_hart_per_socket, imsic_guest_bits; + uint32_t imsic_max_hart_per_socket; uint32_t *imsic_cells, *imsic_regs, imsic_addr, imsic_size; =20 - *msi_m_phandle =3D (*phandle)++; - *msi_s_phandle =3D (*phandle)++; imsic_cells =3D g_new0(uint32_t, ms->smp.cpus * 2); imsic_regs =3D g_new0(uint32_t, socket_count * 4); =20 - /* M-level IMSIC node */ for (cpu =3D 0; cpu < ms->smp.cpus; cpu++) { imsic_cells[cpu * 2 + 0] =3D cpu_to_be32(intc_phandles[cpu]); - imsic_cells[cpu * 2 + 1] =3D cpu_to_be32(IRQ_M_EXT); + imsic_cells[cpu * 2 + 1] =3D cpu_to_be32(m_mode ? IRQ_M_EXT : IRQ_= S_EXT); } - imsic_max_hart_per_socket =3D 0; - for (socket =3D 0; socket < socket_count; socket++) { - imsic_addr =3D memmap[VIRT_IMSIC_M].base + - socket * VIRT_IMSIC_GROUP_MAX_SIZE; - imsic_size =3D IMSIC_HART_SIZE(0) * s->soc[socket].num_harts; - imsic_regs[socket * 4 + 0] =3D 0; - imsic_regs[socket * 4 + 1] =3D cpu_to_be32(imsic_addr); - imsic_regs[socket * 4 + 2] =3D 0; - imsic_regs[socket * 4 + 3] =3D cpu_to_be32(imsic_size); - if (imsic_max_hart_per_socket < s->soc[socket].num_harts) { - imsic_max_hart_per_socket =3D s->soc[socket].num_harts; - } - } - imsic_name =3D g_strdup_printf("/soc/imsics@%lx", - (unsigned long)memmap[VIRT_IMSIC_M].base); - qemu_fdt_add_subnode(ms->fdt, imsic_name); - qemu_fdt_setprop_string(ms->fdt, imsic_name, "compatible", - "riscv,imsics"); - qemu_fdt_setprop_cell(ms->fdt, imsic_name, "#interrupt-cells", - FDT_IMSIC_INT_CELLS); - qemu_fdt_setprop(ms->fdt, imsic_name, "interrupt-controller", - NULL, 0); - qemu_fdt_setprop(ms->fdt, imsic_name, "msi-controller", - NULL, 0); - qemu_fdt_setprop(ms->fdt, imsic_name, "interrupts-extended", - imsic_cells, ms->smp.cpus * sizeof(uint32_t) * 2); - qemu_fdt_setprop(ms->fdt, imsic_name, "reg", imsic_regs, - socket_count * sizeof(uint32_t) * 4); - qemu_fdt_setprop_cell(ms->fdt, imsic_name, "riscv,num-ids", - VIRT_IRQCHIP_NUM_MSIS); - if (socket_count > 1) { - qemu_fdt_setprop_cell(ms->fdt, imsic_name, "riscv,hart-index-bits", - imsic_num_bits(imsic_max_hart_per_socket)); - qemu_fdt_setprop_cell(ms->fdt, imsic_name, "riscv,group-index-bits= ", - imsic_num_bits(socket_count)); - qemu_fdt_setprop_cell(ms->fdt, imsic_name, "riscv,group-index-shif= t", - IMSIC_MMIO_GROUP_MIN_SHIFT); - } - qemu_fdt_setprop_cell(ms->fdt, imsic_name, "phandle", *msi_m_phandle); - - g_free(imsic_name); =20 - /* S-level IMSIC node */ - for (cpu =3D 0; cpu < ms->smp.cpus; cpu++) { - imsic_cells[cpu * 2 + 0] =3D cpu_to_be32(intc_phandles[cpu]); - imsic_cells[cpu * 2 + 1] =3D cpu_to_be32(IRQ_S_EXT); - } - imsic_guest_bits =3D imsic_num_bits(s->aia_guests + 1); imsic_max_hart_per_socket =3D 0; for (socket =3D 0; socket < socket_count; socket++) { - imsic_addr =3D memmap[VIRT_IMSIC_S].base + - socket * VIRT_IMSIC_GROUP_MAX_SIZE; + imsic_addr =3D base_addr + socket * VIRT_IMSIC_GROUP_MAX_SIZE; imsic_size =3D IMSIC_HART_SIZE(imsic_guest_bits) * s->soc[socket].num_harts; imsic_regs[socket * 4 + 0] =3D 0; @@ -599,119 +548,151 @@ static void create_fdt_imsic(RISCVVirtState *s, con= st MemMapEntry *memmap, imsic_max_hart_per_socket =3D s->soc[socket].num_harts; } } - imsic_name =3D g_strdup_printf("/soc/imsics@%lx", - (unsigned long)memmap[VIRT_IMSIC_S].base); + + imsic_name =3D g_strdup_printf("/soc/imsics@%lx", (unsigned long)base_= addr); qemu_fdt_add_subnode(ms->fdt, imsic_name); - qemu_fdt_setprop_string(ms->fdt, imsic_name, "compatible", - "riscv,imsics"); + qemu_fdt_setprop_string(ms->fdt, imsic_name, "compatible", "riscv,imsi= cs"); qemu_fdt_setprop_cell(ms->fdt, imsic_name, "#interrupt-cells", - FDT_IMSIC_INT_CELLS); - qemu_fdt_setprop(ms->fdt, imsic_name, "interrupt-controller", - NULL, 0); - qemu_fdt_setprop(ms->fdt, imsic_name, "msi-controller", - NULL, 0); + FDT_IMSIC_INT_CELLS); + qemu_fdt_setprop(ms->fdt, imsic_name, "interrupt-controller", NULL, 0); + qemu_fdt_setprop(ms->fdt, imsic_name, "msi-controller", NULL, 0); qemu_fdt_setprop(ms->fdt, imsic_name, "interrupts-extended", - imsic_cells, ms->smp.cpus * sizeof(uint32_t) * 2); + imsic_cells, ms->smp.cpus * sizeof(uint32_t) * 2); qemu_fdt_setprop(ms->fdt, imsic_name, "reg", imsic_regs, - socket_count * sizeof(uint32_t) * 4); + socket_count * sizeof(uint32_t) * 4); qemu_fdt_setprop_cell(ms->fdt, imsic_name, "riscv,num-ids", - VIRT_IRQCHIP_NUM_MSIS); + VIRT_IRQCHIP_NUM_MSIS); + if (imsic_guest_bits) { qemu_fdt_setprop_cell(ms->fdt, imsic_name, "riscv,guest-index-bits= ", - imsic_guest_bits); + imsic_guest_bits); } + if (socket_count > 1) { qemu_fdt_setprop_cell(ms->fdt, imsic_name, "riscv,hart-index-bits", - imsic_num_bits(imsic_max_hart_per_socket)); + imsic_num_bits(imsic_max_hart_per_socket)); qemu_fdt_setprop_cell(ms->fdt, imsic_name, "riscv,group-index-bits= ", - imsic_num_bits(socket_count)); + imsic_num_bits(socket_count)); qemu_fdt_setprop_cell(ms->fdt, imsic_name, "riscv,group-index-shif= t", - IMSIC_MMIO_GROUP_MIN_SHIFT); + IMSIC_MMIO_GROUP_MIN_SHIFT); } - qemu_fdt_setprop_cell(ms->fdt, imsic_name, "phandle", *msi_s_phandle); - g_free(imsic_name); + qemu_fdt_setprop_cell(ms->fdt, imsic_name, "phandle", msi_phandle); =20 + g_free(imsic_name); g_free(imsic_regs); g_free(imsic_cells); } =20 -static void create_fdt_socket_aplic(RISCVVirtState *s, - const MemMapEntry *memmap, int socket, - uint32_t msi_m_phandle, - uint32_t msi_s_phandle, - uint32_t *phandle, - uint32_t *intc_phandles, - uint32_t *aplic_phandles) +static void create_fdt_imsic(RISCVVirtState *s, const MemMapEntry *memmap, + uint32_t *phandle, uint32_t *intc_phandles, + uint32_t *msi_m_phandle, uint32_t *msi_s_phan= dle) +{ + *msi_m_phandle =3D (*phandle)++; + *msi_s_phandle =3D (*phandle)++; + + if (!kvm_enabled()) { + /* M-level IMSIC node */ + create_fdt_one_imsic(s, memmap[VIRT_IMSIC_M].base, intc_phandles, + *msi_m_phandle, true, 0); + } + + /* S-level IMSIC node */ + create_fdt_one_imsic(s, memmap[VIRT_IMSIC_S].base, intc_phandles, + *msi_s_phandle, false, + imsic_num_bits(s->aia_guests + 1)); + +} + +static void create_fdt_one_aplic(RISCVVirtState *s, int socket, + unsigned long aplic_addr, uint32_t aplic_= size, + uint32_t msi_phandle, + uint32_t *intc_phandles, + uint32_t aplic_phandle, + uint32_t aplic_child_phandle, + bool m_mode) { int cpu; char *aplic_name; uint32_t *aplic_cells; - unsigned long aplic_addr; MachineState *ms =3D MACHINE(s); - uint32_t aplic_m_phandle, aplic_s_phandle; =20 - aplic_m_phandle =3D (*phandle)++; - aplic_s_phandle =3D (*phandle)++; aplic_cells =3D g_new0(uint32_t, s->soc[socket].num_harts * 2); =20 - /* M-level APLIC node */ for (cpu =3D 0; cpu < s->soc[socket].num_harts; cpu++) { aplic_cells[cpu * 2 + 0] =3D cpu_to_be32(intc_phandles[cpu]); - aplic_cells[cpu * 2 + 1] =3D cpu_to_be32(IRQ_M_EXT); + aplic_cells[cpu * 2 + 1] =3D cpu_to_be32(m_mode ? IRQ_M_EXT : IRQ_= S_EXT); } - aplic_addr =3D memmap[VIRT_APLIC_M].base + - (memmap[VIRT_APLIC_M].size * socket); + aplic_name =3D g_strdup_printf("/soc/aplic@%lx", aplic_addr); qemu_fdt_add_subnode(ms->fdt, aplic_name); qemu_fdt_setprop_string(ms->fdt, aplic_name, "compatible", "riscv,apli= c"); qemu_fdt_setprop_cell(ms->fdt, aplic_name, - "#interrupt-cells", FDT_APLIC_INT_CELLS); + "#interrupt-cells", FDT_APLIC_INT_CELLS); qemu_fdt_setprop(ms->fdt, aplic_name, "interrupt-controller", NULL, 0); + if (s->aia_type =3D=3D VIRT_AIA_TYPE_APLIC) { qemu_fdt_setprop(ms->fdt, aplic_name, "interrupts-extended", - aplic_cells, s->soc[socket].num_harts * sizeof(uint32_t) * 2); + aplic_cells, + s->soc[socket].num_harts * sizeof(uint32_t) * 2); } else { - qemu_fdt_setprop_cell(ms->fdt, aplic_name, "msi-parent", - msi_m_phandle); + qemu_fdt_setprop_cell(ms->fdt, aplic_name, "msi-parent", msi_phand= le); } + qemu_fdt_setprop_cells(ms->fdt, aplic_name, "reg", - 0x0, aplic_addr, 0x0, memmap[VIRT_APLIC_M].size); + 0x0, aplic_addr, 0x0, aplic_size); qemu_fdt_setprop_cell(ms->fdt, aplic_name, "riscv,num-sources", - VIRT_IRQCHIP_NUM_SOURCES); - qemu_fdt_setprop_cell(ms->fdt, aplic_name, "riscv,children", - aplic_s_phandle); - qemu_fdt_setprop_cells(ms->fdt, aplic_name, "riscv,delegate", - aplic_s_phandle, 0x1, VIRT_IRQCHIP_NUM_SOURCES); + VIRT_IRQCHIP_NUM_SOURCES); + + if (aplic_child_phandle) { + qemu_fdt_setprop_cell(ms->fdt, aplic_name, "riscv,children", + aplic_child_phandle); + qemu_fdt_setprop_cells(ms->fdt, aplic_name, "riscv,delegate", + aplic_child_phandle, 0x1, + VIRT_IRQCHIP_NUM_SOURCES); + } + riscv_socket_fdt_write_id(ms, aplic_name, socket); - qemu_fdt_setprop_cell(ms->fdt, aplic_name, "phandle", aplic_m_phandle); + qemu_fdt_setprop_cell(ms->fdt, aplic_name, "phandle", aplic_phandle); + g_free(aplic_name); + g_free(aplic_cells); +} =20 - /* S-level APLIC node */ - for (cpu =3D 0; cpu < s->soc[socket].num_harts; cpu++) { - aplic_cells[cpu * 2 + 0] =3D cpu_to_be32(intc_phandles[cpu]); - aplic_cells[cpu * 2 + 1] =3D cpu_to_be32(IRQ_S_EXT); +static void create_fdt_socket_aplic(RISCVVirtState *s, + const MemMapEntry *memmap, int socket, + uint32_t msi_m_phandle, + uint32_t msi_s_phandle, + uint32_t *phandle, + uint32_t *intc_phandles, + uint32_t *aplic_phandles) +{ + char *aplic_name; + unsigned long aplic_addr; + MachineState *ms =3D MACHINE(s); + uint32_t aplic_m_phandle, aplic_s_phandle; + + aplic_m_phandle =3D (*phandle)++; + aplic_s_phandle =3D (*phandle)++; + + if (!kvm_enabled()) { + /* M-level APLIC node */ + aplic_addr =3D memmap[VIRT_APLIC_M].base + + (memmap[VIRT_APLIC_M].size * socket); + create_fdt_one_aplic(s, socket, aplic_addr, memmap[VIRT_APLIC_M].s= ize, + msi_m_phandle, intc_phandles, + aplic_m_phandle, aplic_s_phandle, + true); } + + /* S-level APLIC node */ aplic_addr =3D memmap[VIRT_APLIC_S].base + (memmap[VIRT_APLIC_S].size * socket); + create_fdt_one_aplic(s, socket, aplic_addr, memmap[VIRT_APLIC_S].size, + msi_s_phandle, intc_phandles, + aplic_s_phandle, 0, + false); + aplic_name =3D g_strdup_printf("/soc/aplic@%lx", aplic_addr); - qemu_fdt_add_subnode(ms->fdt, aplic_name); - qemu_fdt_setprop_string(ms->fdt, aplic_name, "compatible", "riscv,apli= c"); - qemu_fdt_setprop_cell(ms->fdt, aplic_name, - "#interrupt-cells", FDT_APLIC_INT_CELLS); - qemu_fdt_setprop(ms->fdt, aplic_name, "interrupt-controller", NULL, 0); - if (s->aia_type =3D=3D VIRT_AIA_TYPE_APLIC) { - qemu_fdt_setprop(ms->fdt, aplic_name, "interrupts-extended", - aplic_cells, s->soc[socket].num_harts * sizeof(uint32_t) * 2); - } else { - qemu_fdt_setprop_cell(ms->fdt, aplic_name, "msi-parent", - msi_s_phandle); - } - qemu_fdt_setprop_cells(ms->fdt, aplic_name, "reg", - 0x0, aplic_addr, 0x0, memmap[VIRT_APLIC_S].size); - qemu_fdt_setprop_cell(ms->fdt, aplic_name, "riscv,num-sources", - VIRT_IRQCHIP_NUM_SOURCES); - riscv_socket_fdt_write_id(ms, aplic_name, socket); - qemu_fdt_setprop_cell(ms->fdt, aplic_name, "phandle", aplic_s_phandle); =20 if (!socket) { platform_bus_add_all_fdt_nodes(ms->fdt, aplic_name, @@ -722,7 +703,6 @@ static void create_fdt_socket_aplic(RISCVVirtState *s, =20 g_free(aplic_name); =20 - g_free(aplic_cells); aplic_phandles[socket] =3D aplic_s_phandle; } =20 @@ -1163,16 +1143,20 @@ static DeviceState *virt_create_aia(RISCVVirtAIATyp= e aia_type, int aia_guests, int i; hwaddr addr; uint32_t guest_bits; - DeviceState *aplic_m; - bool msimode =3D (aia_type =3D=3D VIRT_AIA_TYPE_APLIC_IMSIC) ? true : = false; + DeviceState *aplic_s =3D NULL; + DeviceState *aplic_m =3D NULL; + bool msimode =3D aia_type =3D=3D VIRT_AIA_TYPE_APLIC_IMSIC; =20 if (msimode) { - /* Per-socket M-level IMSICs */ - addr =3D memmap[VIRT_IMSIC_M].base + socket * VIRT_IMSIC_GROUP_MAX= _SIZE; - for (i =3D 0; i < hart_count; i++) { - riscv_imsic_create(addr + i * IMSIC_HART_SIZE(0), - base_hartid + i, true, 1, - VIRT_IRQCHIP_NUM_MSIS); + if (!kvm_enabled()) { + /* Per-socket M-level IMSICs */ + addr =3D memmap[VIRT_IMSIC_M].base + + socket * VIRT_IMSIC_GROUP_MAX_SIZE; + for (i =3D 0; i < hart_count; i++) { + riscv_imsic_create(addr + i * IMSIC_HART_SIZE(0), + base_hartid + i, true, 1, + VIRT_IRQCHIP_NUM_MSIS); + } } =20 /* Per-socket S-level IMSICs */ @@ -1185,29 +1169,29 @@ static DeviceState *virt_create_aia(RISCVVirtAIATyp= e aia_type, int aia_guests, } } =20 - /* Per-socket M-level APLIC */ - aplic_m =3D riscv_aplic_create( - memmap[VIRT_APLIC_M].base + socket * memmap[VIRT_APLIC_M].size, - memmap[VIRT_APLIC_M].size, - (msimode) ? 0 : base_hartid, - (msimode) ? 0 : hart_count, - VIRT_IRQCHIP_NUM_SOURCES, - VIRT_IRQCHIP_NUM_PRIO_BITS, - msimode, true, NULL); - - if (aplic_m) { - /* Per-socket S-level APLIC */ - riscv_aplic_create( - memmap[VIRT_APLIC_S].base + socket * memmap[VIRT_APLIC_S].size, - memmap[VIRT_APLIC_S].size, - (msimode) ? 0 : base_hartid, - (msimode) ? 0 : hart_count, - VIRT_IRQCHIP_NUM_SOURCES, - VIRT_IRQCHIP_NUM_PRIO_BITS, - msimode, false, aplic_m); + if (!kvm_enabled()) { + /* Per-socket M-level APLIC */ + aplic_m =3D riscv_aplic_create(memmap[VIRT_APLIC_M].base + + socket * memmap[VIRT_APLIC_M].size, + memmap[VIRT_APLIC_M].size, + (msimode) ? 0 : base_hartid, + (msimode) ? 0 : hart_count, + VIRT_IRQCHIP_NUM_SOURCES, + VIRT_IRQCHIP_NUM_PRIO_BITS, + msimode, true, NULL); } =20 - return aplic_m; + /* Per-socket S-level APLIC */ + aplic_s =3D riscv_aplic_create(memmap[VIRT_APLIC_S].base + + socket * memmap[VIRT_APLIC_S].size, + memmap[VIRT_APLIC_S].size, + (msimode) ? 0 : base_hartid, + (msimode) ? 0 : hart_count, + VIRT_IRQCHIP_NUM_SOURCES, + VIRT_IRQCHIP_NUM_PRIO_BITS, + msimode, false, aplic_m); + + return kvm_enabled() ? aplic_s : aplic_m; } =20 static void create_platform_bus(RISCVVirtState *s, DeviceState *irqchip) --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153499; cv=none; d=zohomail.com; s=zohoarc; b=OfLeEjza2qwjkP/+d13HBinKkp3eg7ER8iNfDsgIq82SDKiisB+OctF3SKyeIHzl6JkeQCBQfGrNhU482L/5JRWBnFtzOeututC1vMquvC8pqPmKRRkCoDKhGqPQ718jy/s57FmX4hM+67ntQo+KxyFr0OXfaglzb14QmXZy3/M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153499; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vLQpbDK+vhuZxw59pu2RWadiyahlNw5xeOR7KVVdyRM=; b=l/a5azDE/szKNX4CBdNxRSAFneYp6GxJ5hHnDizWANGLGwMWdZVF1AEjKaB4/BteRLRND33M64EhMYSMp/M3TkSM/RVkFy32gFNWJhd8krWl40fvoVcqZTNWOVRFNRPCynXCAgAaGSCADtrviJp48jUWd9J1/U6LnVBiyrPH7kU= 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 1694153499232189.59127115622516; Thu, 7 Sep 2023 23:11:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUdu-0003je-CU; Fri, 08 Sep 2023 02:06:58 -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 1qeUdq-00038r-DZ for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:54 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUdo-0006W0-2R for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:54 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1c06f6f98c0so13945335ad.3 for ; Thu, 07 Sep 2023 23:06:51 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.06.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:06:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153210; x=1694758010; 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=vLQpbDK+vhuZxw59pu2RWadiyahlNw5xeOR7KVVdyRM=; b=UHFJBevJ9D4QCcvNIVO2BSF+a5ZIbIv+W4VAtYZGhqjVofkt0+kAI/3jYmb0iyR5Sq dudHYLa2Cj6UnkB6ilUJjFmU2OhJySrrTB53gDAJ0Omdj0pXDjiwai3Jtvq/WvCrxD7A BQpQ0U2X/gUaZvtydRC48l+B6nBRYDGG4U27MOBKWY11mPhIMBPGpOQNs27JOHJMUj3Q 4DYX0TyeukJQpZ/Qv359pmffb5kdiPr0ka0UlugAgF49U4txwAdhMhI/X2F58LoKiFF7 juQx8Qaznqw6XkD2tNPLBbAQHn0qH8LyaXbWIj5lXKWocwKWotnXhZIBSXcoiJo0l1Kl QdIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153210; x=1694758010; 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=vLQpbDK+vhuZxw59pu2RWadiyahlNw5xeOR7KVVdyRM=; b=wInLeencRGurxtxU8G72AxbJO3NIvrqrHZkJGx6LblxTmhWtaYYEgIQplcrN9QpJbN 6jPjXROc3QzsE/asTwuOn8UNp9ek5sqZohZoXePPn5NJAksFbL9ebYRuHcwbb5I5auFb ZYVkrofixJdHOOwW8K8tyJTmdjuf5Q6pAtmCNZYty4T1GEmHnfIveNHrJ+gdETof7590 V7RbemHwCq4YeJ3Um7MeCQZkuNQ3AJCaVTkZTpvVgfMwnFntNm+NgA+HeCR2WYN86+UW xJRVRzHWpicEi5FtGmFxN4OagsBOrwoha5PCb+gtti3y+lW9P8hl7Y1C7JfJB0ebvotn yC7w== X-Gm-Message-State: AOJu0Yw4kqSCvN9lCHl0Wuylkx85CC25MFGkbRU/Zr2VcxwMWrrVPEgn X8myKlkEtm3E43ebmmPe0W6D48YB5/qXuIRT X-Google-Smtp-Source: AGHT+IF4Jc6fLiiBf4wDe1+7kJlBT5rHB8TezB5mx6qHTn3qiWPlp0a3mFKzmqm1yq0DG2N0qlez/w== X-Received: by 2002:a17:902:da92:b0:1bb:a522:909a with SMTP id j18-20020a170902da9200b001bba522909amr2153787plx.37.1694153210483; Thu, 07 Sep 2023 23:06:50 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Yong-Xuan Wang , Jim Shu , Daniel Henrique Barboza , Andrew Jones , Alistair Francis Subject: [PULL 30/65] target/riscv: check the in-kernel irqchip support Date: Fri, 8 Sep 2023 16:03:56 +1000 Message-ID: <20230908060431.1903919-31-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::635; envelope-from=alistair23@gmail.com; helo=mail-pl1-x635.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: 1694153499473100001 Content-Type: text/plain; charset="utf-8" From: Yong-Xuan Wang We check the in-kernel irqchip support when using KVM acceleration. Signed-off-by: Yong-Xuan Wang Reviewed-by: Jim Shu Reviewed-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Message-ID: <20230727102439.22554-3-yongxuan.wang@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/kvm.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/target/riscv/kvm.c b/target/riscv/kvm.c index dbcf26f27d..2953547cb6 100644 --- a/target/riscv/kvm.c +++ b/target/riscv/kvm.c @@ -926,7 +926,15 @@ int kvm_arch_init(MachineState *ms, KVMState *s) =20 int kvm_arch_irqchip_create(KVMState *s) { - return 0; + if (kvm_kernel_irqchip_split()) { + error_report("-machine kernel_irqchip=3Dsplit is not supported on = RISC-V."); + exit(1); + } + + /* + * We can create the VAIA using the newer device control API. + */ + return kvm_check_extension(s, KVM_CAP_DEVICE_CTRL); } =20 int kvm_arch_process_async_events(CPUState *cs) --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153527; cv=none; d=zohomail.com; s=zohoarc; b=M5InEIx2SqOKYMIR9ESsz6xr41+Uo8t+UTXp4zHCtIcrsWVBxMs/l+JziA0SdRz6DEgGVddEyfkl7rSceeCRcj/JGYVO9S8XwHD5qoWZw7VgOUQ61vjUmDflnRAtBNT3RDe5ahpdVW/cviA7dOdoBoAPSf5kPfMWzsFrZQKzzGg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153527; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YFC/Wd1PZEGT1vXAEy/Fv/qkqYKA8VvtbmwE/sCiNlE=; b=g5AZgGQ/k+eXpohxSeHRcs7nr6lEZ20SOLVMkKonnAT8TaLzdZjYB5Od0cIhpO50rcoNb4v3VGc9NJyyup0qndwAYkNQKyX1O9jQBnwvT+eaK9yvzM+yizVCYQyCsmWRP8cjkqI1d5qJ0+nr4tUGBoIW2D6dcQys7pCMyQFjIPU= 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 1694153527288500.53721754941114; Thu, 7 Sep 2023 23:12:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUdy-00049V-3h; Fri, 08 Sep 2023 02:07:02 -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 1qeUdv-0003vQ-Hl for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:59 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUds-0006Wa-GT for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:06:59 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1c1f8aaab9aso14771075ad.1 for ; Thu, 07 Sep 2023 23:06:56 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.06.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:06:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153214; x=1694758014; 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=YFC/Wd1PZEGT1vXAEy/Fv/qkqYKA8VvtbmwE/sCiNlE=; b=SzggFB3poeOPTgMsn/VVhUZAAb7UX/AmZeq/HDFVnHMnCDDXbn0+7wTL6kUQL++9XX QVq26ddCUH09dFR35ljgArviAP/NgIs5JVB2Titr/BYsRyvQbOZo9dpPp8V86ELXdvZj zTh0Ie17TMSpgzXRiYa/RM0nGiRiHcxfMSrOg55zVzDUKTIBezFQ91pbKGWKDFELw2f7 C9am93B0qGHKRg1qjXde6G1Ktx6qVUQbgCmE5krzUUD5T9t6AZsBEfYGbdXXKJQjCAZb yIXkIJuUtPy2GnaMD3Ysot7ss/bsUIDFqr3O7rH1YcbrmhOpr6aHDFy/n5wlMx5KnpX5 S37Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153214; x=1694758014; 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=YFC/Wd1PZEGT1vXAEy/Fv/qkqYKA8VvtbmwE/sCiNlE=; b=Yet0rpnL9GlJpYO8C7Vx/7Ucg4RFziZj023exkiyVgAl6/vSb6a025VQNJL0A0io80 T3rGYbVvwV7pkPuFTUoIs2K02uFU8267mNVlfQm3tqg7lLMoVN4HTaJkU3GgxnBvNhrv SU910jXqwWxgyaV56cv3+ky8rBgOdy7h11HQDFRfYT0wQl7TBXc3hszbSVBXmebny3Tf MOqG7zONxuSCTa533/M82/c7lwClqtZsr++yKuXW4zXWuiOkYZUeEtM0jXJbFp+aSB88 K54jk0/5YBfD3dZK5MYvY2pdmm1dXMukYae3fGdbuyRRWoPRXcvTgbxis9FVzTvXrMJp wHDg== X-Gm-Message-State: AOJu0YwBe5COzLJDcZe/876cl8e3gvzrX0s3fZWd3khHB/pw8lhzSXLp 1zcRvHnAUfeDvJ+mTA7U1te903++NE1dgeLa X-Google-Smtp-Source: AGHT+IETlzgjeG7GJWqeJMN8KGJilPSjlKpysMsiBDpa2ctynYijNRLrt+cJ4Vv0uDT0wCOnZVWkGQ== X-Received: by 2002:a17:902:ec88:b0:1c0:d19a:9829 with SMTP id x8-20020a170902ec8800b001c0d19a9829mr1637501plg.25.1694153214381; Thu, 07 Sep 2023 23:06:54 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Yong-Xuan Wang , Jim Shu , Daniel Henrique Barboza , Andrew Jones , Alistair Francis Subject: [PULL 31/65] target/riscv: Create an KVM AIA irqchip Date: Fri, 8 Sep 2023 16:03:57 +1000 Message-ID: <20230908060431.1903919-32-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::62b; envelope-from=alistair23@gmail.com; helo=mail-pl1-x62b.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: 1694153528210100001 Content-Type: text/plain; charset="utf-8" From: Yong-Xuan Wang We create a vAIA chip by using the KVM_DEV_TYPE_RISCV_AIA and then set up the chip with the KVM_DEV_RISCV_AIA_GRP_* APIs. We also extend KVM accelerator to specify the KVM AIA mode. The "riscv-aia" parameter is passed along with --accel in QEMU command-line. 1) "riscv-aia=3Demul": IMSIC is emulated by hypervisor 2) "riscv-aia=3Dhwaccel": use hardware guest IMSIC 3) "riscv-aia=3Dauto": use the hardware guest IMSICs whenever available otherwise we fallback to software emulation. Signed-off-by: Yong-Xuan Wang Reviewed-by: Jim Shu Reviewed-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Message-ID: <20230727102439.22554-4-yongxuan.wang@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/kvm_riscv.h | 4 + target/riscv/kvm.c | 186 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 190 insertions(+) diff --git a/target/riscv/kvm_riscv.h b/target/riscv/kvm_riscv.h index e3ba935808..7d4b7c60e2 100644 --- a/target/riscv/kvm_riscv.h +++ b/target/riscv/kvm_riscv.h @@ -22,5 +22,9 @@ void kvm_riscv_init_user_properties(Object *cpu_obj); void kvm_riscv_reset_vcpu(RISCVCPU *cpu); void kvm_riscv_set_irq(RISCVCPU *cpu, int irq, int level); +void kvm_riscv_aia_create(MachineState *machine, uint64_t group_shift, + uint64_t aia_irq_num, uint64_t aia_msi_num, + uint64_t aplic_base, uint64_t imsic_base, + uint64_t guest_num); =20 #endif diff --git a/target/riscv/kvm.c b/target/riscv/kvm.c index 2953547cb6..6e909d0fdd 100644 --- a/target/riscv/kvm.c +++ b/target/riscv/kvm.c @@ -36,6 +36,7 @@ #include "exec/address-spaces.h" #include "hw/boards.h" #include "hw/irq.h" +#include "hw/intc/riscv_imsic.h" #include "qemu/log.h" #include "hw/loader.h" #include "kvm_riscv.h" @@ -43,6 +44,7 @@ #include "chardev/char-fe.h" #include "migration/migration.h" #include "sysemu/runstate.h" +#include "hw/riscv/numa.h" =20 static uint64_t kvm_riscv_reg_id(CPURISCVState *env, uint64_t type, uint64_t idx) @@ -1035,6 +1037,190 @@ bool kvm_arch_cpu_check_are_resettable(void) return true; } =20 +static int aia_mode; + +static const char *kvm_aia_mode_str(uint64_t mode) +{ + switch (mode) { + case KVM_DEV_RISCV_AIA_MODE_EMUL: + return "emul"; + case KVM_DEV_RISCV_AIA_MODE_HWACCEL: + return "hwaccel"; + case KVM_DEV_RISCV_AIA_MODE_AUTO: + default: + return "auto"; + }; +} + +static char *riscv_get_kvm_aia(Object *obj, Error **errp) +{ + return g_strdup(kvm_aia_mode_str(aia_mode)); +} + +static void riscv_set_kvm_aia(Object *obj, const char *val, Error **errp) +{ + if (!strcmp(val, "emul")) { + aia_mode =3D KVM_DEV_RISCV_AIA_MODE_EMUL; + } else if (!strcmp(val, "hwaccel")) { + aia_mode =3D KVM_DEV_RISCV_AIA_MODE_HWACCEL; + } else if (!strcmp(val, "auto")) { + aia_mode =3D KVM_DEV_RISCV_AIA_MODE_AUTO; + } else { + error_setg(errp, "Invalid KVM AIA mode"); + error_append_hint(errp, "Valid values are emul, hwaccel, and auto.= \n"); + } +} + void kvm_arch_accel_class_init(ObjectClass *oc) { + object_class_property_add_str(oc, "riscv-aia", riscv_get_kvm_aia, + riscv_set_kvm_aia); + object_class_property_set_description(oc, "riscv-aia", + "Set KVM AIA mode. Valid values = are " + "emul, hwaccel, and auto. Defaul= t " + "is auto."); + object_property_set_default_str(object_class_property_find(oc, "riscv-= aia"), + "auto"); +} + +void kvm_riscv_aia_create(MachineState *machine, uint64_t group_shift, + uint64_t aia_irq_num, uint64_t aia_msi_num, + uint64_t aplic_base, uint64_t imsic_base, + uint64_t guest_num) +{ + int ret, i; + int aia_fd =3D -1; + uint64_t default_aia_mode; + uint64_t socket_count =3D riscv_socket_count(machine); + uint64_t max_hart_per_socket =3D 0; + uint64_t socket, base_hart, hart_count, socket_imsic_base, imsic_addr; + uint64_t socket_bits, hart_bits, guest_bits; + + aia_fd =3D kvm_create_device(kvm_state, KVM_DEV_TYPE_RISCV_AIA, false); + + if (aia_fd < 0) { + error_report("Unable to create in-kernel irqchip"); + exit(1); + } + + ret =3D kvm_device_access(aia_fd, KVM_DEV_RISCV_AIA_GRP_CONFIG, + KVM_DEV_RISCV_AIA_CONFIG_MODE, + &default_aia_mode, false, NULL); + if (ret < 0) { + error_report("KVM AIA: failed to get current KVM AIA mode"); + exit(1); + } + qemu_log("KVM AIA: default mode is %s\n", + kvm_aia_mode_str(default_aia_mode)); + + if (default_aia_mode !=3D aia_mode) { + ret =3D kvm_device_access(aia_fd, KVM_DEV_RISCV_AIA_GRP_CONFIG, + KVM_DEV_RISCV_AIA_CONFIG_MODE, + &aia_mode, true, NULL); + if (ret < 0) + warn_report("KVM AIA: failed to set KVM AIA mode"); + else + qemu_log("KVM AIA: set current mode to %s\n", + kvm_aia_mode_str(aia_mode)); + } + + ret =3D kvm_device_access(aia_fd, KVM_DEV_RISCV_AIA_GRP_CONFIG, + KVM_DEV_RISCV_AIA_CONFIG_SRCS, + &aia_irq_num, true, NULL); + if (ret < 0) { + error_report("KVM AIA: failed to set number of input irq lines"); + exit(1); + } + + ret =3D kvm_device_access(aia_fd, KVM_DEV_RISCV_AIA_GRP_CONFIG, + KVM_DEV_RISCV_AIA_CONFIG_IDS, + &aia_msi_num, true, NULL); + if (ret < 0) { + error_report("KVM AIA: failed to set number of msi"); + exit(1); + } + + socket_bits =3D find_last_bit(&socket_count, BITS_PER_LONG) + 1; + ret =3D kvm_device_access(aia_fd, KVM_DEV_RISCV_AIA_GRP_CONFIG, + KVM_DEV_RISCV_AIA_CONFIG_GROUP_BITS, + &socket_bits, true, NULL); + if (ret < 0) { + error_report("KVM AIA: failed to set group_bits"); + exit(1); + } + + ret =3D kvm_device_access(aia_fd, KVM_DEV_RISCV_AIA_GRP_CONFIG, + KVM_DEV_RISCV_AIA_CONFIG_GROUP_SHIFT, + &group_shift, true, NULL); + if (ret < 0) { + error_report("KVM AIA: failed to set group_shift"); + exit(1); + } + + guest_bits =3D guest_num =3D=3D 0 ? 0 : + find_last_bit(&guest_num, BITS_PER_LONG) + 1; + ret =3D kvm_device_access(aia_fd, KVM_DEV_RISCV_AIA_GRP_CONFIG, + KVM_DEV_RISCV_AIA_CONFIG_GUEST_BITS, + &guest_bits, true, NULL); + if (ret < 0) { + error_report("KVM AIA: failed to set guest_bits"); + exit(1); + } + + ret =3D kvm_device_access(aia_fd, KVM_DEV_RISCV_AIA_GRP_ADDR, + KVM_DEV_RISCV_AIA_ADDR_APLIC, + &aplic_base, true, NULL); + if (ret < 0) { + error_report("KVM AIA: failed to set the base address of APLIC"); + exit(1); + } + + for (socket =3D 0; socket < socket_count; socket++) { + socket_imsic_base =3D imsic_base + socket * (1U << group_shift); + hart_count =3D riscv_socket_hart_count(machine, socket); + base_hart =3D riscv_socket_first_hartid(machine, socket); + + if (max_hart_per_socket < hart_count) { + max_hart_per_socket =3D hart_count; + } + + for (i =3D 0; i < hart_count; i++) { + imsic_addr =3D socket_imsic_base + i * IMSIC_HART_SIZE(guest_b= its); + ret =3D kvm_device_access(aia_fd, KVM_DEV_RISCV_AIA_GRP_ADDR, + KVM_DEV_RISCV_AIA_ADDR_IMSIC(i + base_= hart), + &imsic_addr, true, NULL); + if (ret < 0) { + error_report("KVM AIA: failed to set the IMSIC address for= hart %d", i); + exit(1); + } + } + } + + hart_bits =3D find_last_bit(&max_hart_per_socket, BITS_PER_LONG) + 1; + ret =3D kvm_device_access(aia_fd, KVM_DEV_RISCV_AIA_GRP_CONFIG, + KVM_DEV_RISCV_AIA_CONFIG_HART_BITS, + &hart_bits, true, NULL); + if (ret < 0) { + error_report("KVM AIA: failed to set hart_bits"); + exit(1); + } + + if (kvm_has_gsi_routing()) { + for (uint64_t idx =3D 0; idx < aia_irq_num + 1; ++idx) { + /* KVM AIA only has one APLIC instance */ + kvm_irqchip_add_irq_route(kvm_state, idx, 0, idx); + } + kvm_gsi_routing_allowed =3D true; + kvm_irqchip_commit_routes(kvm_state); + } + + ret =3D kvm_device_access(aia_fd, KVM_DEV_RISCV_AIA_GRP_CTRL, + KVM_DEV_RISCV_AIA_CTRL_INIT, + NULL, true, NULL); + if (ret < 0) { + error_report("KVM AIA: initialized fail"); + exit(1); + } + + kvm_msi_via_irqfd_allowed =3D kvm_irqfds_enabled(); } --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153399; cv=none; d=zohomail.com; s=zohoarc; b=lt2raXCirKjqFo07VHzdOr2UBvhqJIsKyJCLliEDhve7nsLVvI55zrGH/8c9ef8/7Ai/vqSDfwR0A5ZuOpgAHqEmj/GnJqnytkWD/XPX5AIrWnh+d4AVDJBYiuHmZpJ7NR3c/1L/ROY1O8/fegrIKG8AnFB1Gr5cb7lMyEtveUU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153399; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LC1iRCb/qoM78YnEP3ofg9nP8nM+h7xg35CBjBCHbHg=; b=G6GN+Iy4m3KrmvG/G9x2/KVvxbMNqDLni72BsHz5Mtiy5dcaLvFisoIN8prLXc+C7c+CiYkr2RG6ieOWG3igkTHXe4lNDrYvMvszRFi1hgUBERp47ohbuPoCe1Oyv996E4fqQi9A5EO14WEXeIJAcqFnzJmEQDozK+PlsTSTbZo= 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 1694153399869103.47545899238503; Thu, 7 Sep 2023 23:09:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUe1-0004Ui-C1; Fri, 08 Sep 2023 02:07:05 -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 1qeUdz-0004Iw-53 for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:03 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUdw-0006Xh-7a for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:02 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1bc8a2f71eeso14848215ad.0 for ; Thu, 07 Sep 2023 23:06:59 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.06.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:06:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153218; x=1694758018; 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=LC1iRCb/qoM78YnEP3ofg9nP8nM+h7xg35CBjBCHbHg=; b=hS3htWtoJHn4JI6pA8MRcpm0YC/SnO9R8wHKqzQRlCCPSDYptUObHtT6cT2yTZfuLm /rCDhWHV0pJcEseRuv1fffHfINzmSYtwO80f9M0G1iPml3fYE8LDM2ZwJUYKynVpgzit eczTCr6crKNsyQ6tGQoQak/VbSHaNAiR2gUGTHmU8izpCROUAVLp/K8w/f9bRr8kVTOh 5okfND9bh/gEU/awEHy7NxjTRX57DFbFwGyHmOawL+BF1Nig274Sap5iRCwF3Hio3KEj gsjuOOw9blhrw2jS00C8Tt0z8dOxf++20jFSTBsUvVpxtzgpC9tE6yPpnWOxyQz66lTI MOuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153218; x=1694758018; 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=LC1iRCb/qoM78YnEP3ofg9nP8nM+h7xg35CBjBCHbHg=; b=m5bSlFQaDSVwzTdakLreczF+YFnT3YTxM17l2MMe/Ni9Tl9svWYwvNwmZvoeSGfklg sBJKaYAqK7e0uIVM42xuSa0s9KV9GtA+CiGRlBPS90mnYgGIcelyj6bJphWe34tEKKUU pTYNa1/evUSyk9Zg/mYFlxd6mJBZ5hcguWJFS/PoZGVCo73NPgajuU7tKySSxE/ml/mV gnF5qbX2fB54WKKHvPpGVUdKQbdCJKa7pJd5s7Ch9T/r9jnOHdjOgutvH2zVpIavm7Fa DHZABgvnXi49cRLgA0xEB9VBpjC1Fs6EuhASkxdQOSv0JEy5vTvkXzzxZCl12vdGJTXe Rlaw== X-Gm-Message-State: AOJu0Yzwuuk0a8rj4KT957zMsYRTff5fsPN/4r3+mCAE1/aiRr3R31YO 6Pc2AQyuYmC7tXdmtC3Uytck1zCenEIOg4na X-Google-Smtp-Source: AGHT+IFfWv1GmyIdO3JIejM485TOadT74WYATLo4SY7TxZ4zuaMj/llhDuRRvK/ZI7w+RBBZOk/0xw== X-Received: by 2002:a17:903:1c5:b0:1b8:865d:6e1d with SMTP id e5-20020a17090301c500b001b8865d6e1dmr1649351plh.51.1694153218392; Thu, 07 Sep 2023 23:06:58 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Yong-Xuan Wang , Jim Shu , Daniel Henrique Barboza , Andrew Jones , Alistair Francis Subject: [PULL 32/65] target/riscv: update APLIC and IMSIC to support KVM AIA Date: Fri, 8 Sep 2023 16:03:58 +1000 Message-ID: <20230908060431.1903919-33-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::635; envelope-from=alistair23@gmail.com; helo=mail-pl1-x635.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: 1694153401885100011 Content-Type: text/plain; charset="utf-8" From: Yong-Xuan Wang KVM AIA can't emulate APLIC only. When "aia=3Daplic" parameter is passed, APLIC devices is emulated by QEMU. For "aia=3Daplic-imsic", remove the mmio operations of APLIC when using KVM AIA and send wired interrupt signal via KVM_IRQ_LINE API. After KVM AIA enabled, MSI messages are delivered by KVM_SIGNAL_MSI API when the IMSICs receive mmio write requests. Signed-off-by: Yong-Xuan Wang Reviewed-by: Jim Shu Reviewed-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Message-ID: <20230727102439.22554-5-yongxuan.wang@sifive.com> Signed-off-by: Alistair Francis --- hw/intc/riscv_aplic.c | 56 ++++++++++++++++++++++++++++++------------- hw/intc/riscv_imsic.c | 25 +++++++++++++++---- 2 files changed, 61 insertions(+), 20 deletions(-) diff --git a/hw/intc/riscv_aplic.c b/hw/intc/riscv_aplic.c index 4bdc6a5d1a..592c3ce768 100644 --- a/hw/intc/riscv_aplic.c +++ b/hw/intc/riscv_aplic.c @@ -31,6 +31,7 @@ #include "hw/irq.h" #include "target/riscv/cpu.h" #include "sysemu/sysemu.h" +#include "sysemu/kvm.h" #include "migration/vmstate.h" =20 #define APLIC_MAX_IDC (1UL << 14) @@ -148,6 +149,15 @@ =20 #define APLIC_IDC_CLAIMI 0x1c =20 +/* + * KVM AIA only supports APLIC MSI, fallback to QEMU emulation if we want = to use + * APLIC Wired. + */ +static bool is_kvm_aia(bool msimode) +{ + return kvm_irqchip_in_kernel() && msimode; +} + static uint32_t riscv_aplic_read_input_word(RISCVAPLICState *aplic, uint32_t word) { @@ -471,6 +481,11 @@ static uint32_t riscv_aplic_idc_claimi(RISCVAPLICState= *aplic, uint32_t idc) return topi; } =20 +static void riscv_kvm_aplic_request(void *opaque, int irq, int level) +{ + kvm_set_irq(kvm_state, irq, !!level); +} + static void riscv_aplic_request(void *opaque, int irq, int level) { bool update =3D false; @@ -801,29 +816,35 @@ static void riscv_aplic_realize(DeviceState *dev, Err= or **errp) uint32_t i; RISCVAPLICState *aplic =3D RISCV_APLIC(dev); =20 - aplic->bitfield_words =3D (aplic->num_irqs + 31) >> 5; - aplic->sourcecfg =3D g_new0(uint32_t, aplic->num_irqs); - aplic->state =3D g_new0(uint32_t, aplic->num_irqs); - aplic->target =3D g_new0(uint32_t, aplic->num_irqs); - if (!aplic->msimode) { - for (i =3D 0; i < aplic->num_irqs; i++) { - aplic->target[i] =3D 1; + if (!is_kvm_aia(aplic->msimode)) { + aplic->bitfield_words =3D (aplic->num_irqs + 31) >> 5; + aplic->sourcecfg =3D g_new0(uint32_t, aplic->num_irqs); + aplic->state =3D g_new0(uint32_t, aplic->num_irqs); + aplic->target =3D g_new0(uint32_t, aplic->num_irqs); + if (!aplic->msimode) { + for (i =3D 0; i < aplic->num_irqs; i++) { + aplic->target[i] =3D 1; + } } - } - aplic->idelivery =3D g_new0(uint32_t, aplic->num_harts); - aplic->iforce =3D g_new0(uint32_t, aplic->num_harts); - aplic->ithreshold =3D g_new0(uint32_t, aplic->num_harts); + aplic->idelivery =3D g_new0(uint32_t, aplic->num_harts); + aplic->iforce =3D g_new0(uint32_t, aplic->num_harts); + aplic->ithreshold =3D g_new0(uint32_t, aplic->num_harts); =20 - memory_region_init_io(&aplic->mmio, OBJECT(dev), &riscv_aplic_ops, apl= ic, - TYPE_RISCV_APLIC, aplic->aperture_size); - sysbus_init_mmio(SYS_BUS_DEVICE(dev), &aplic->mmio); + memory_region_init_io(&aplic->mmio, OBJECT(dev), &riscv_aplic_ops, + aplic, TYPE_RISCV_APLIC, aplic->aperture_siz= e); + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &aplic->mmio); + } =20 /* * Only root APLICs have hardware IRQ lines. All non-root APLICs * have IRQ lines delegated by their parent APLIC. */ if (!aplic->parent) { - qdev_init_gpio_in(dev, riscv_aplic_request, aplic->num_irqs); + if (is_kvm_aia(aplic->msimode)) { + qdev_init_gpio_in(dev, riscv_kvm_aplic_request, aplic->num_irq= s); + } else { + qdev_init_gpio_in(dev, riscv_aplic_request, aplic->num_irqs); + } } =20 /* Create output IRQ lines for non-MSI mode */ @@ -958,7 +979,10 @@ DeviceState *riscv_aplic_create(hwaddr addr, hwaddr si= ze, qdev_prop_set_bit(dev, "mmode", mmode); =20 sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); - sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, addr); + + if (!is_kvm_aia(msimode)) { + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, addr); + } =20 if (parent) { riscv_aplic_add_child(parent, dev); diff --git a/hw/intc/riscv_imsic.c b/hw/intc/riscv_imsic.c index fea3385b51..760dbddcf7 100644 --- a/hw/intc/riscv_imsic.c +++ b/hw/intc/riscv_imsic.c @@ -32,6 +32,7 @@ #include "target/riscv/cpu.h" #include "target/riscv/cpu_bits.h" #include "sysemu/sysemu.h" +#include "sysemu/kvm.h" #include "migration/vmstate.h" =20 #define IMSIC_MMIO_PAGE_LE 0x00 @@ -283,6 +284,20 @@ static void riscv_imsic_write(void *opaque, hwaddr add= r, uint64_t value, goto err; } =20 +#if defined(CONFIG_KVM) + if (kvm_irqchip_in_kernel()) { + struct kvm_msi msi; + + msi.address_lo =3D extract64(imsic->mmio.addr + addr, 0, 32); + msi.address_hi =3D extract64(imsic->mmio.addr + addr, 32, 32); + msi.data =3D le32_to_cpu(value); + + kvm_vm_ioctl(kvm_state, KVM_SIGNAL_MSI, &msi); + + return; + } +#endif + /* Writes only supported for MSI little-endian registers */ page =3D addr >> IMSIC_MMIO_PAGE_SHIFT; if ((addr & (IMSIC_MMIO_PAGE_SZ - 1)) =3D=3D IMSIC_MMIO_PAGE_LE) { @@ -320,10 +335,12 @@ static void riscv_imsic_realize(DeviceState *dev, Err= or **errp) CPUState *cpu =3D cpu_by_arch_id(imsic->hartid); CPURISCVState *env =3D cpu ? cpu->env_ptr : NULL; =20 - imsic->num_eistate =3D imsic->num_pages * imsic->num_irqs; - imsic->eidelivery =3D g_new0(uint32_t, imsic->num_pages); - imsic->eithreshold =3D g_new0(uint32_t, imsic->num_pages); - imsic->eistate =3D g_new0(uint32_t, imsic->num_eistate); + if (!kvm_irqchip_in_kernel()) { + imsic->num_eistate =3D imsic->num_pages * imsic->num_irqs; + imsic->eidelivery =3D g_new0(uint32_t, imsic->num_pages); + imsic->eithreshold =3D g_new0(uint32_t, imsic->num_pages); + imsic->eistate =3D g_new0(uint32_t, imsic->num_eistate); + } =20 memory_region_init_io(&imsic->mmio, OBJECT(dev), &riscv_imsic_ops, imsic, TYPE_RISCV_IMSIC, --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153387; cv=none; d=zohomail.com; s=zohoarc; b=iIGqtGb0fD1PfqVOxfz7IXQmhdf5DgjnAs4yErG/UVshXkkDACoCf6tOHqzC7b/5KAG0nAiy9gOy79rT2rDOivMMhNHwSFdpdbbWkazVa9rC0rpwUkKaePE7acbdlk2FiAbn8CfifgRx3+rXKiD6Fk9FfvYk4M4Z+uo1RYKLaDs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153387; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HQFAilQXwavviYSAdbF8h1VfNWuIPepi8QcpnGv5OOw=; b=Zql4SZHDWCsZg4XqeypQLhNwTPoWdQk+QL0OR/mlvngv8r0u7icuP9Ugb8tKN6M6l1V4g6Wb2oSlbc8Io6tdq8Q6A8JMKikYGBFQNz4fFCGDHRDTVeh+1iil7v5Ib8qr5bdqLEkuqiOV8rvjCb5E0B3s49ilGeRUXnYyBwF9p74= 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 1694153387322436.51097492729264; Thu, 7 Sep 2023 23:09:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUe5-0004zb-Ny; Fri, 08 Sep 2023 02:07:09 -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 1qeUe3-0004kK-Ja for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:07 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUe0-0006ic-Ub for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:07 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1bdc19b782aso13623125ad.0 for ; Thu, 07 Sep 2023 23:07:04 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.06.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:07:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153223; x=1694758023; 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=HQFAilQXwavviYSAdbF8h1VfNWuIPepi8QcpnGv5OOw=; b=QtYmuc81Bj03PzU2qpXL2DuSOl+Pi2a+DT2Xgq23ZipW6MS3A0/Dzfjg+O3eJIByx6 1wuMbsjKMAE/LStren0Z3y2hdRl5TTwYSgxdwXZgm9430q7SqoX37/j2vE7OuEdD1Iji x3Avlqv9RPl+o/hSGF4xoznSVLbp+stAY2U/pYFshKePz3n1PSXTyZsUVubIryTWO196 aObXy0Mko98ItrdoPj58Zyle/JqW/Zi3HsFobRE47hEHj/Yj890hKmAqousOm8mNhHWC jwLM4UJ4CF45YqKxL7PaeLNfeEEyTYK7kB3LnM7cAtqsYPfcNfxEx5IVdI0Nq0/OtsKC ++9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153223; x=1694758023; 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=HQFAilQXwavviYSAdbF8h1VfNWuIPepi8QcpnGv5OOw=; b=oRuvHNZjSwXqBlj6zptkVLV6fJWLFR6LnoC4Z0RTYYl7phC92wl9vRioCOrs3PzaCK R+2z/R3cOU6aPS9J8xBH7oN20HoGBwjzeK9nNfe4eie+OKrIkNLeC0A1shegSovCwewQ eNqLME+AoHZc28UAfp+JUBf8mhQCDk/yBhlrbXeUZj97o5CPV53kltzswcHaEPTxf9Rc iDeYgkrmr8EBHC3xmbBiP2NaU6rt4yC1wCDGwoTxZnntYf9NqRJtSuZOqHAdqscwpIzb qvgNngc93jPgIV+TBt3gPcXkY7i3rbaEPl2xom0AKdg6anyFdYP6uKq76MSNWDbZR5yL FBqA== X-Gm-Message-State: AOJu0YyLXdkXwlqFR7ILAy9nQ0jMn6qLOoUv1Wilb+1MhCO4zeqaYFyf Io2llqgdZTS7LpOUyG5z57Ud97p/s+Sy8C84 X-Google-Smtp-Source: AGHT+IFfE+aWr6CxXfQlJunOmEVwYwCAKW1TAUXLHJvnUDNMN+LWheU5aV2VAjs8nWDOWY+ea972Tw== X-Received: by 2002:a17:903:1104:b0:1bd:c105:e07e with SMTP id n4-20020a170903110400b001bdc105e07emr2115663plh.6.1694153222780; Thu, 07 Sep 2023 23:07:02 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Yong-Xuan Wang , Jim Shu , Daniel Henrique Barboza , Andrew Jones , Alistair Francis Subject: [PULL 33/65] target/riscv: select KVM AIA in riscv virt machine Date: Fri, 8 Sep 2023 16:03:59 +1000 Message-ID: <20230908060431.1903919-34-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::62a; envelope-from=alistair23@gmail.com; helo=mail-pl1-x62a.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: 1694153388580100003 Content-Type: text/plain; charset="utf-8" From: Yong-Xuan Wang Select KVM AIA when the host kernel has in-kernel AIA chip support. Since KVM AIA only has one APLIC instance, we map the QEMU APLIC devices to KVM APLIC. Signed-off-by: Yong-Xuan Wang Reviewed-by: Jim Shu Reviewed-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Message-ID: <20230727102439.22554-6-yongxuan.wang@sifive.com> Signed-off-by: Alistair Francis --- hw/riscv/virt.c | 94 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 31 deletions(-) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 693b2df8df..a0f7b5abf9 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -35,6 +35,7 @@ #include "hw/riscv/virt.h" #include "hw/riscv/boot.h" #include "hw/riscv/numa.h" +#include "kvm_riscv.h" #include "hw/intc/riscv_aclint.h" #include "hw/intc/riscv_aplic.h" #include "hw/intc/riscv_imsic.h" @@ -75,6 +76,12 @@ #error "Can't accomodate all IMSIC groups in address space" #endif =20 +/* KVM AIA only supports APLIC MSI. APLIC Wired is always emulated by QEMU= . */ +static bool virt_use_kvm_aia(RISCVVirtState *s) +{ + return kvm_irqchip_in_kernel() && s->aia_type =3D=3D VIRT_AIA_TYPE_APL= IC_IMSIC; +} + static const MemMapEntry virt_memmap[] =3D { [VIRT_DEBUG] =3D { 0x0, 0x100 }, [VIRT_MROM] =3D { 0x1000, 0xf000 }, @@ -609,16 +616,16 @@ static void create_fdt_one_aplic(RISCVVirtState *s, i= nt socket, uint32_t *intc_phandles, uint32_t aplic_phandle, uint32_t aplic_child_phandle, - bool m_mode) + bool m_mode, int num_harts) { int cpu; char *aplic_name; uint32_t *aplic_cells; MachineState *ms =3D MACHINE(s); =20 - aplic_cells =3D g_new0(uint32_t, s->soc[socket].num_harts * 2); + aplic_cells =3D g_new0(uint32_t, num_harts * 2); =20 - for (cpu =3D 0; cpu < s->soc[socket].num_harts; cpu++) { + for (cpu =3D 0; cpu < num_harts; cpu++) { aplic_cells[cpu * 2 + 0] =3D cpu_to_be32(intc_phandles[cpu]); aplic_cells[cpu * 2 + 1] =3D cpu_to_be32(m_mode ? IRQ_M_EXT : IRQ_= S_EXT); } @@ -632,8 +639,7 @@ static void create_fdt_one_aplic(RISCVVirtState *s, int= socket, =20 if (s->aia_type =3D=3D VIRT_AIA_TYPE_APLIC) { qemu_fdt_setprop(ms->fdt, aplic_name, "interrupts-extended", - aplic_cells, - s->soc[socket].num_harts * sizeof(uint32_t) * 2); + aplic_cells, num_harts * sizeof(uint32_t) * 2); } else { qemu_fdt_setprop_cell(ms->fdt, aplic_name, "msi-parent", msi_phand= le); } @@ -664,7 +670,8 @@ static void create_fdt_socket_aplic(RISCVVirtState *s, uint32_t msi_s_phandle, uint32_t *phandle, uint32_t *intc_phandles, - uint32_t *aplic_phandles) + uint32_t *aplic_phandles, + int num_harts) { char *aplic_name; unsigned long aplic_addr; @@ -681,7 +688,7 @@ static void create_fdt_socket_aplic(RISCVVirtState *s, create_fdt_one_aplic(s, socket, aplic_addr, memmap[VIRT_APLIC_M].s= ize, msi_m_phandle, intc_phandles, aplic_m_phandle, aplic_s_phandle, - true); + true, num_harts); } =20 /* S-level APLIC node */ @@ -690,7 +697,7 @@ static void create_fdt_socket_aplic(RISCVVirtState *s, create_fdt_one_aplic(s, socket, aplic_addr, memmap[VIRT_APLIC_S].size, msi_s_phandle, intc_phandles, aplic_s_phandle, 0, - false); + false, num_harts); =20 aplic_name =3D g_strdup_printf("/soc/aplic@%lx", aplic_addr); =20 @@ -774,34 +781,51 @@ static void create_fdt_sockets(RISCVVirtState *s, con= st MemMapEntry *memmap, *msi_pcie_phandle =3D msi_s_phandle; } =20 - phandle_pos =3D ms->smp.cpus; - for (socket =3D (socket_count - 1); socket >=3D 0; socket--) { - phandle_pos -=3D s->soc[socket].num_harts; - - if (s->aia_type =3D=3D VIRT_AIA_TYPE_NONE) { - create_fdt_socket_plic(s, memmap, socket, phandle, - &intc_phandles[phandle_pos], xplic_phandles); - } else { - create_fdt_socket_aplic(s, memmap, socket, - msi_m_phandle, msi_s_phandle, phandle, - &intc_phandles[phandle_pos], xplic_phandles); + /* KVM AIA only has one APLIC instance */ + if (virt_use_kvm_aia(s)) { + create_fdt_socket_aplic(s, memmap, 0, + msi_m_phandle, msi_s_phandle, phandle, + &intc_phandles[0], xplic_phandles, + ms->smp.cpus); + } else { + phandle_pos =3D ms->smp.cpus; + for (socket =3D (socket_count - 1); socket >=3D 0; socket--) { + phandle_pos -=3D s->soc[socket].num_harts; + + if (s->aia_type =3D=3D VIRT_AIA_TYPE_NONE) { + create_fdt_socket_plic(s, memmap, socket, phandle, + &intc_phandles[phandle_pos], + xplic_phandles); + } else { + create_fdt_socket_aplic(s, memmap, socket, + msi_m_phandle, msi_s_phandle, phan= dle, + &intc_phandles[phandle_pos], + xplic_phandles, + s->soc[socket].num_harts); + } } } =20 g_free(intc_phandles); =20 - for (socket =3D 0; socket < socket_count; socket++) { - if (socket =3D=3D 0) { - *irq_mmio_phandle =3D xplic_phandles[socket]; - *irq_virtio_phandle =3D xplic_phandles[socket]; - *irq_pcie_phandle =3D xplic_phandles[socket]; - } - if (socket =3D=3D 1) { - *irq_virtio_phandle =3D xplic_phandles[socket]; - *irq_pcie_phandle =3D xplic_phandles[socket]; - } - if (socket =3D=3D 2) { - *irq_pcie_phandle =3D xplic_phandles[socket]; + if (virt_use_kvm_aia(s)) { + *irq_mmio_phandle =3D xplic_phandles[0]; + *irq_virtio_phandle =3D xplic_phandles[0]; + *irq_pcie_phandle =3D xplic_phandles[0]; + } else { + for (socket =3D 0; socket < socket_count; socket++) { + if (socket =3D=3D 0) { + *irq_mmio_phandle =3D xplic_phandles[socket]; + *irq_virtio_phandle =3D xplic_phandles[socket]; + *irq_pcie_phandle =3D xplic_phandles[socket]; + } + if (socket =3D=3D 1) { + *irq_virtio_phandle =3D xplic_phandles[socket]; + *irq_pcie_phandle =3D xplic_phandles[socket]; + } + if (socket =3D=3D 2) { + *irq_pcie_phandle =3D xplic_phandles[socket]; + } } } =20 @@ -1437,6 +1461,14 @@ static void virt_machine_init(MachineState *machine) } } =20 + if (virt_use_kvm_aia(s)) { + kvm_riscv_aia_create(machine, IMSIC_MMIO_GROUP_MIN_SHIFT, + VIRT_IRQCHIP_NUM_SOURCES, VIRT_IRQCHIP_NUM_MS= IS, + memmap[VIRT_APLIC_S].base, + memmap[VIRT_IMSIC_S].base, + s->aia_guests); + } + if (riscv_is_32bit(&s->soc[0])) { #if HOST_LONG_BITS =3D=3D 64 /* limit RAM size in a 32-bit system */ --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153656; cv=none; d=zohomail.com; s=zohoarc; b=c4AJStQIKsUU+FORkW/mmFJNtF2b5FTKhjKDOpdeujHlsyarIFQMtAsWVimacnN57A6ot7ksDqj5CKvUP1j9RO9lEUHBzPTHdm7f/0bfK8VKlWn/8/sN9Sb2FEO+jXckgvdIiE69uE+V9MExMMYqN/KWRKgppmYlzuXlF+VrObs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153656; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hxlq5Geudrn5K7zUDOYOIODn69Bkkfse0taaW1zZPXI=; b=ZTpsJ1O90sXkUOvTEu/Zm3KBZwyuDrEMv9/K2n+6zjRaBJgj2BZl1th1/Hg9aL+QtDsqEerFNlSX7mN9oxlE/EDtvIg3R5Uejbzs2+zUXoyNQPlfgCv5h09WFmXS9MXZqVEwcPh3KZkD/q/rdQBHPFguluh4QZH6+1qufY5dh94= 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 1694153656451395.7860053207445; Thu, 7 Sep 2023 23:14:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUe8-0005Fz-51; Fri, 08 Sep 2023 02:07:12 -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 1qeUe6-00056v-BI for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:10 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUe3-0006qs-OE for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:10 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1bf57366ccdso20254885ad.1 for ; Thu, 07 Sep 2023 23:07:07 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.07.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:07:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153226; x=1694758026; 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=hxlq5Geudrn5K7zUDOYOIODn69Bkkfse0taaW1zZPXI=; b=GLfIo22COcLfY82Z4iUF7oDiA0gYqaXy37BQJJuas3atdGfriR5KhRt3PIsIdAILJY QpzbgAcq5WV4yStt/f8E/p8KYjVXsfcQbHlecnFwORGfwHC7LbM1YHYsTXeWuFog9ErW Aqbg0TOEwlhy8IQN+aILYFFPdAMrZ1ql8Cr1qZNnM9DAPhShsgZMOoaDw64cPHVJVzc9 8ehQtl9Rp7aE9n99Sp9fa6bQeq6edqizgKIr9+BevCiDe3fvKMHJFpZJipI3D+3EAebq 5iyIPNTQh+Ck5cMLRP72twR4r0ouX2PuDJMs5oJCDMU0FjRvh2mi88xXqG0VfxTchsb8 LFsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153226; x=1694758026; 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=hxlq5Geudrn5K7zUDOYOIODn69Bkkfse0taaW1zZPXI=; b=NHdOnQz7bVCVrkhhKZBXnrnyiD+sVoRf2D02XOY6K8njljC8/h9bnQcgesGnraE3kw Fi2htsXB4rocZncbGAeeVwz27lnnZQpqB/1CbdfW5eiPi9V1eyzro+jAvIPfVEXu52GU X93c+qViIWzbrtUDdZIILREOjXTthG4CM8Uivis6qxaqS1o119XEj/KJEEXT0t7Q9Q/B pfnSrJE3lJL0S70KZ2MCPSPfnsO1dUzJR/cg8l/nZFB1buQCdF3Tc6alQXvaPv1ozzu8 R5FMyTTbZV7t+9W6b2QH1lF7m65VmOMzWfXNU1AuavKuMCwP69Gaj4DTNuLg+EkeIRSr TV3g== X-Gm-Message-State: AOJu0Yxu8AZrsZG4JL4xlzE1QQVAxmlZCITD2Ur2uSnYMHh7VrJJuXXD sPhCUGLxQqvfdpcOWh4Zm5eIrGfOC4CDPVlR X-Google-Smtp-Source: AGHT+IHIGNGAZmCUL78LfchooGWliY4YMpOsQ6e4Ebzsw585LZcNcJIWQG9EmgMTtobQj9zVE7YXHQ== X-Received: by 2002:a17:902:da91:b0:1bd:f69e:a407 with SMTP id j17-20020a170902da9100b001bdf69ea407mr7039092plx.8.1694153226150; Thu, 07 Sep 2023 23:07:06 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Conor Dooley , Alistair Francis , Daniel Henrique Barboza Subject: [PULL 34/65] hw/riscv: virt: Fix riscv,pmu DT node path Date: Fri, 8 Sep 2023 16:04:00 +1000 Message-ID: <20230908060431.1903919-35-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::635; envelope-from=alistair23@gmail.com; helo=mail-pl1-x635.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: 1694153658175100007 Content-Type: text/plain; charset="utf-8" From: Conor Dooley On a dtb dumped from the virt machine, dt-validate complains: soc: pmu: {'riscv,event-to-mhpmcounters': [[1, 1, 524281], [2, 2, 524284], = [65561, 65561, 524280], [65563, 65563, 524280], [65569, 65569, 524280]], 'c= ompatible': ['riscv,pmu']} should not be valid under {'type': 'object'} from schema $id: http://devicetree.org/schemas/simple-bus.yaml# That's pretty cryptic, but running the dtb back through dtc produces something a lot more reasonable: Warning (simple_bus_reg): /soc/pmu: missing or empty reg/ranges property Moving the riscv,pmu node out of the soc bus solves the problem. Signed-off-by: Conor Dooley Acked-by: Alistair Francis Reviewed-by: Daniel Henrique Barboza Message-ID: <20230727-groom-decline-2c57ce42841c@spud> Signed-off-by: Alistair Francis --- hw/riscv/virt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index a0f7b5abf9..388e52a294 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -719,7 +719,7 @@ static void create_fdt_pmu(RISCVVirtState *s) MachineState *ms =3D MACHINE(s); RISCVCPU hart =3D s->soc[0].harts[0]; =20 - pmu_name =3D g_strdup_printf("/soc/pmu"); + pmu_name =3D g_strdup_printf("/pmu"); qemu_fdt_add_subnode(ms->fdt, pmu_name); qemu_fdt_setprop_string(ms->fdt, pmu_name, "compatible", "riscv,pmu"); riscv_pmu_generate_fdt_node(ms->fdt, hart.cfg.pmu_num, pmu_name); --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153241; cv=none; d=zohomail.com; s=zohoarc; b=nuXME2lMQE9SFYPCCONfeRu7ejszzSYX/TOStMzkbOIK1XF5x7WUSgokbU6QDfjyq7h8BNpN/F+RO1GS+jFMBLRm4Du7slVBu5tVht+cNPHHa01rsJn0qsXBsSyywzc8vsFuEnmgp2hkzdbzPPw2IZsVhdI/qMpyAV3IFNj/3cM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153241; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2zKj+0PvJXMdpPtyy+4HtEgZTt3YDZpe426jZ7MOFzA=; b=WazyIJMxz9tKVYGMQkLvaqHFkSf1MGazgNgcyUNEKbE/N7MKKsbksV6nS2m2jTNKJC/Czsue1YTZ4BUmQZKqzfJw4LcoszHWKryOrZCpkrGywgaG3VbvB6zXJMlghC2eoh4f/vMGfnTN+KN+DBSdGXFabj3E/b4BOF/BTtUVoEg= 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 1694153241216614.4258397144056; Thu, 7 Sep 2023 23:07:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUeB-0005cb-U4; Fri, 08 Sep 2023 02:07:15 -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 1qeUeA-0005UK-Cj for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:14 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUe7-00074k-L1 for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:13 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1c0bae4da38so12131415ad.0 for ; Thu, 07 Sep 2023 23:07:11 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.07.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:07:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153230; x=1694758030; 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=2zKj+0PvJXMdpPtyy+4HtEgZTt3YDZpe426jZ7MOFzA=; b=VlS45unhTKTu+Rs/sCyYDcGAEh9IwZ25SXnyhOrnJ2DrhZ3KaLz5D8ieq6O2hDR3tW LdeTzYQwj1TeNmYw9SpK5Kfo+SQDSrLzC7hmUtIrv2F+A/LDhYqtxt4JsmKohSxTNzjm Nre0jilFSACBMytJOmV0y2Hxv8YRogEOH3lYLORwItmvqiDTXs2xPIf+oXxJTQvu+l+l 6yV5ozeJma2jc2tPTv6osHIKQvCBk8UpF56/yv4XjDZEr57wuxM0Mx1yGzPwMtl/9/YE XHSqlJRkwJ0in/EEjjgNCGAncPNLpJFSLwKN3Cwl5n81fl0QByfpVCm7zzawVbMn+5Se L3Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153230; x=1694758030; 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=2zKj+0PvJXMdpPtyy+4HtEgZTt3YDZpe426jZ7MOFzA=; b=MAoJ2n3FOvgTYD8+1EB4D2SFh9QFwaG9Kn0/C6E9MJF7hplnJRVfyBMnS2VbeCUAX+ iVN02H3bKJu3MtZHy/4UBio2kRZi7NUS1/TvdbzFYoG8hLzoKBWbStdrD7+JE+fnpPKV hWmhA41jBOX9MaIz6MjuDNag/4Wzcfcn8+lmFKPkQ34QAleSyBHrQLN2wi0t/lZxsiQi MIV/DDwM9g7PcuoWnWRj4H6ImM8YmBfoCiRnXyhixskRznqIo6xPVEgH9+8dsDl6rqyN BxNigUinI2FdJfC/Jsy0SoEuHKlobCdBSHADRJTEsY8wI42sn4AtkLpL2WQ4RCB3zNFY KLSw== X-Gm-Message-State: AOJu0Yznjo1kdWGatJO/W9Jx83xKxijetPLJiYlUAS+4IsmKmKOcwJmq WzKhUYwdrpfDyTVoqCpCrS3KVJz8MMGEz24c X-Google-Smtp-Source: AGHT+IGKkn03rcItxatgAflNKsWdNY8X0+bYQ71IFR6rBKb7l4j5fQvxYoYu6i/eLNbQGBgw8hAcFA== X-Received: by 2002:a17:902:8ec2:b0:1bb:85cd:9190 with SMTP id x2-20020a1709028ec200b001bb85cd9190mr1722333plo.18.1694153229792; Thu, 07 Sep 2023 23:07:09 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Weiwei Li , Junqiang Wang , Daniel Henrique Barboza , Alistair Francis Subject: [PULL 35/65] target/riscv: Update CSR bits name for svadu extension Date: Fri, 8 Sep 2023 16:04:01 +1000 Message-ID: <20230908060431.1903919-36-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::62b; envelope-from=alistair23@gmail.com; helo=mail-pl1-x62b.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: 1694153241751100005 Content-Type: text/plain; charset="utf-8" From: Weiwei Li The Svadu specification updated the name of the *envcfg bit from HADE to ADUE. Signed-off-by: Weiwei Li Signed-off-by: Junqiang Wang Reviewed-by: Daniel Henrique Barboza Message-ID: <20230816141916.66898-1-liweiwei@iscas.ac.cn> Signed-off-by: Alistair Francis --- target/riscv/cpu_bits.h | 8 ++++---- target/riscv/cpu.c | 4 ++-- target/riscv/cpu_helper.c | 6 +++--- target/riscv/csr.c | 12 ++++++------ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index 59f0ffd9e1..1c2ffae883 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -745,12 +745,12 @@ typedef enum RISCVException { #define MENVCFG_CBIE (3UL << 4) #define MENVCFG_CBCFE BIT(6) #define MENVCFG_CBZE BIT(7) -#define MENVCFG_HADE (1ULL << 61) +#define MENVCFG_ADUE (1ULL << 61) #define MENVCFG_PBMTE (1ULL << 62) #define MENVCFG_STCE (1ULL << 63) =20 /* For RV32 */ -#define MENVCFGH_HADE BIT(29) +#define MENVCFGH_ADUE BIT(29) #define MENVCFGH_PBMTE BIT(30) #define MENVCFGH_STCE BIT(31) =20 @@ -763,12 +763,12 @@ typedef enum RISCVException { #define HENVCFG_CBIE MENVCFG_CBIE #define HENVCFG_CBCFE MENVCFG_CBCFE #define HENVCFG_CBZE MENVCFG_CBZE -#define HENVCFG_HADE MENVCFG_HADE +#define HENVCFG_ADUE MENVCFG_ADUE #define HENVCFG_PBMTE MENVCFG_PBMTE #define HENVCFG_STCE MENVCFG_STCE =20 /* For RV32 */ -#define HENVCFGH_HADE MENVCFGH_HADE +#define HENVCFGH_ADUE MENVCFGH_ADUE #define HENVCFGH_PBMTE MENVCFGH_PBMTE #define HENVCFGH_STCE MENVCFGH_STCE =20 diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index fae1c92c5c..8071f05f15 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -886,9 +886,9 @@ static void riscv_cpu_reset_hold(Object *obj) env->two_stage_lookup =3D false; =20 env->menvcfg =3D (cpu->cfg.ext_svpbmt ? MENVCFG_PBMTE : 0) | - (cpu->cfg.ext_svadu ? MENVCFG_HADE : 0); + (cpu->cfg.ext_svadu ? MENVCFG_ADUE : 0); env->henvcfg =3D (cpu->cfg.ext_svpbmt ? HENVCFG_PBMTE : 0) | - (cpu->cfg.ext_svadu ? HENVCFG_HADE : 0); + (cpu->cfg.ext_svadu ? HENVCFG_ADUE : 0); =20 /* Initialized default priorities of local interrupts. */ for (i =3D 0; i < ARRAY_SIZE(env->miprio); i++) { diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 9f611d89bb..3a02079290 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -861,11 +861,11 @@ static int get_physical_address(CPURISCVState *env, h= waddr *physical, } =20 bool pbmte =3D env->menvcfg & MENVCFG_PBMTE; - bool hade =3D env->menvcfg & MENVCFG_HADE; + bool adue =3D env->menvcfg & MENVCFG_ADUE; =20 if (first_stage && two_stage && env->virt_enabled) { pbmte =3D pbmte && (env->henvcfg & HENVCFG_PBMTE); - hade =3D hade && (env->henvcfg & HENVCFG_HADE); + adue =3D adue && (env->henvcfg & HENVCFG_ADUE); } =20 int ptshift =3D (levels - 1) * ptidxbits; @@ -1026,7 +1026,7 @@ restart: =20 /* Page table updates need to be atomic with MTTCG enabled */ if (updated_pte !=3D pte && !is_debug) { - if (!hade) { + if (!adue) { return TRANSLATE_FAIL; } =20 diff --git a/target/riscv/csr.c b/target/riscv/csr.c index e4490d5bed..b8e0d0cb4c 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -1957,7 +1957,7 @@ static RISCVException write_menvcfg(CPURISCVState *en= v, int csrno, if (riscv_cpu_mxl(env) =3D=3D MXL_RV64) { mask |=3D (cfg->ext_svpbmt ? MENVCFG_PBMTE : 0) | (cfg->ext_sstc ? MENVCFG_STCE : 0) | - (cfg->ext_svadu ? MENVCFG_HADE : 0); + (cfg->ext_svadu ? MENVCFG_ADUE : 0); } env->menvcfg =3D (env->menvcfg & ~mask) | (val & mask); =20 @@ -1977,7 +1977,7 @@ static RISCVException write_menvcfgh(CPURISCVState *e= nv, int csrno, const RISCVCPUConfig *cfg =3D riscv_cpu_cfg(env); uint64_t mask =3D (cfg->ext_svpbmt ? MENVCFG_PBMTE : 0) | (cfg->ext_sstc ? MENVCFG_STCE : 0) | - (cfg->ext_svadu ? MENVCFG_HADE : 0); + (cfg->ext_svadu ? MENVCFG_ADUE : 0); uint64_t valh =3D (uint64_t)val << 32; =20 env->menvcfg =3D (env->menvcfg & ~mask) | (valh & mask); @@ -2029,7 +2029,7 @@ static RISCVException read_henvcfg(CPURISCVState *env= , int csrno, * henvcfg.stce is read_only 0 when menvcfg.stce =3D 0 * henvcfg.hade is read_only 0 when menvcfg.hade =3D 0 */ - *val =3D env->henvcfg & (~(HENVCFG_PBMTE | HENVCFG_STCE | HENVCFG_HADE= ) | + *val =3D env->henvcfg & (~(HENVCFG_PBMTE | HENVCFG_STCE | HENVCFG_ADUE= ) | env->menvcfg); return RISCV_EXCP_NONE; } @@ -2046,7 +2046,7 @@ static RISCVException write_henvcfg(CPURISCVState *en= v, int csrno, } =20 if (riscv_cpu_mxl(env) =3D=3D MXL_RV64) { - mask |=3D env->menvcfg & (HENVCFG_PBMTE | HENVCFG_STCE | HENVCFG_H= ADE); + mask |=3D env->menvcfg & (HENVCFG_PBMTE | HENVCFG_STCE | HENVCFG_A= DUE); } =20 env->henvcfg =3D (env->henvcfg & ~mask) | (val & mask); @@ -2064,7 +2064,7 @@ static RISCVException read_henvcfgh(CPURISCVState *en= v, int csrno, return ret; } =20 - *val =3D (env->henvcfg & (~(HENVCFG_PBMTE | HENVCFG_STCE | HENVCFG_HAD= E) | + *val =3D (env->henvcfg & (~(HENVCFG_PBMTE | HENVCFG_STCE | HENVCFG_ADU= E) | env->menvcfg)) >> 32; return RISCV_EXCP_NONE; } @@ -2073,7 +2073,7 @@ static RISCVException write_henvcfgh(CPURISCVState *e= nv, int csrno, target_ulong val) { uint64_t mask =3D env->menvcfg & (HENVCFG_PBMTE | HENVCFG_STCE | - HENVCFG_HADE); + HENVCFG_ADUE); uint64_t valh =3D (uint64_t)val << 32; RISCVException ret; =20 --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153263; cv=none; d=zohomail.com; s=zohoarc; b=XwcFnkxgF5vG70XyAWz9sNEKxacPMLzvhfGOrgx22Njs0eHtIJj2KQw0lReI/1EchXOnG8cRJYmbt5qc/LpyLZdfaPca9TsXQkQ84RQUZys+xnQFAHkmjNuwxXFVRv/tICEdjoEB6pELPa4cMdID6nvPTS6AooYcvlsoZXFaexE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153263; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YOggPHEkVLsqxPB2c0/QeriqcmfD3a3w+0iFBDdTsWI=; b=V9C6KG3a9S5sIhwsbFBRgDoY1Jz5kBBa95xYKlKFg3VjF6ZOPyzFQgNUeUaCYiUfGIYWzgQjjdXw5xldvx4EKgCmGHJvl5QMwhCq+jqRR02HrTa+KL+evLKAgYk99WBH+QLgbzohrjIkMh0AjAjSt6cYvmqvCeG2fw4F3DM32yg= 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 1694153263048926.2499403763181; Thu, 7 Sep 2023 23:07:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUeF-0005uF-C9; Fri, 08 Sep 2023 02:07:19 -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 1qeUeD-0005l8-Ph for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:17 -0400 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 1qeUeB-00079g-AL for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:17 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1bc0d39b52cso13618915ad.2 for ; Thu, 07 Sep 2023 23:07:14 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.07.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:07:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153233; x=1694758033; 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=YOggPHEkVLsqxPB2c0/QeriqcmfD3a3w+0iFBDdTsWI=; b=qQNiAOySXxETlowiZEq7uthi1d0R7KoVjmiRB5/A+Onzmx4swX9qmIyBQRLlEfCYyi pr/C1XIyTbWJGFL/LQWtA92iaUWdFuwHlhKMLb5LgEdVk/NhqqPgoOrT6gZxL9MakLEZ Lt2pgFLCyYs6PZH/PjVwikOb1377/DYZFz13p9qcwR5zgufpnFZudrnUH4Pef18NSb6i aH3qnaKzERpkb82peSctv5A8PgMIn5QiLgGiLadfzcWYKz5y7gL8qnZdVYfpcdPuClio WBRyZIlNYub/RcJkTGTQrk/RT5ld7ERZg749aVR1Ivb6eMQtp380YtC26PRmx/EJzgTg xqJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153233; x=1694758033; 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=YOggPHEkVLsqxPB2c0/QeriqcmfD3a3w+0iFBDdTsWI=; b=iZ2BTFGnFHljFCrIxzm/cqszwvdMBSYLBfm4p1W4F6uNjuKFfjJPNENfwnJA95myxj 66C7xEkJjZJnyQ2Pgkz/ILmoMzQysa0vwBdMeZlH5JGPgFnkCawNEH6yCkiBVsmuH4Pv SC6GziFLhFNwg1PO/ShloIgzMSwI8cgeiVpEW1BC/+dgUqKNJYEjGirFSO6BNxlAVTQ1 8FcTAYhGi3xw9c/TG39S5xFi31ncUN+JmUD092Ll7LdFIsq5Tdjk6xIjNAGLe/PiTavu A0Npl6aR2Xd0eyJAQhU44BFen+OLWiETsE85jSq2FL7J3z/XXfpJzxBwO6nEj0rLlGdU g2TQ== X-Gm-Message-State: AOJu0YzBpoi9TiLm82d8mgsSmuAVO3EEYOU3ao0I7FeCdRZvjr4wwJpj fKRQOEMUUa0zHdFduQ1TxmmVs5s0ykqPFfM+ X-Google-Smtp-Source: AGHT+IEFQPBB2uWMM9KfROu3u+0B50z6lbpR/Bre+27YmCBE/JcTAURSXkIQ+SCJ4Dr6ZdBkj7s5kg== X-Received: by 2002:a17:902:d507:b0:1bf:22b7:86d with SMTP id b7-20020a170902d50700b001bf22b7086dmr1796584plg.3.1694153233488; Thu, 07 Sep 2023 23:07:13 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Alexandre Ghiti , Andrew Jones , Alistair Francis Subject: [PULL 36/65] target/riscv: fix satp_mode_finalize() when satp_mode.supported = 0 Date: Fri, 8 Sep 2023 16:04:02 +1000 Message-ID: <20230908060431.1903919-37-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::62f; envelope-from=alistair23@gmail.com; helo=mail-pl1-x62f.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: 1694153265077100003 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza In the same emulated RISC-V host, the 'host' KVM CPU takes 4 times longer to boot than the 'rv64' KVM CPU. The reason is an unintended behavior of riscv_cpu_satp_mode_finalize() when satp_mode.supported =3D 0, i.e. when cpu_init() does not set satp_mode_max_supported(). satp_mode_max_from_map(map) does: 31 - __builtin_clz(map) This means that, if satp_mode.supported =3D 0, satp_mode_supported_max wil be '31 - 32'. But this is C, so satp_mode_supported_max will gladly set it to UINT_MAX (4294967295). After that, if the user didn't set a satp_mode, set_satp_mode_default_map(cpu) will make cfg.satp_mode.map =3D cfg.satp_mode.supported So satp_mode.map =3D 0. And then satp_mode_map_max will be set to satp_mode_max_from_map(cpu->cfg.satp_mode.map), i.e. also UINT_MAX. The guard "satp_mode_map_max > satp_mode_supported_max" doesn't protect us here since both are UINT_MAX. And finally we have 2 loops: for (int i =3D satp_mode_map_max - 1; i >=3D 0; --i) { Which are, in fact, 2 loops from UINT_MAX -1 to -1. This is where the extra delay when booting the 'host' CPU is coming from. Commit 43d1de32f8 already set a precedence for satp_mode.supported =3D 0 in a different manner. We're doing the same here. If supported =3D=3D 0, interpret as 'the CPU wants the OS to handle satp mode alone' and skip satp_mode_finalize(). We'll also put a guard in satp_mode_max_from_map() to assert out if map is 0 since the function is not ready to deal with it. Cc: Alexandre Ghiti Fixes: 6f23aaeb9b ("riscv: Allow user to set the satp mode") Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Message-ID: <20230817152903.694926-1-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 8071f05f15..34ac26e3ae 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -309,6 +309,17 @@ static uint8_t satp_mode_from_str(const char *satp_mod= e_str) =20 uint8_t satp_mode_max_from_map(uint32_t map) { + /* + * 'map =3D 0' will make us return (31 - 32), which C will + * happily overflow to UINT_MAX. There's no good result to + * return if 'map =3D 0' (e.g. returning 0 will be ambiguous + * with the result for 'map =3D 1'). + * + * Assert out if map =3D 0. Callers will have to deal with + * it outside of this function. + */ + g_assert(map > 0); + /* map here has at least one bit set, so no problem with clz */ return 31 - __builtin_clz(map); } @@ -1333,9 +1344,15 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu= , Error **errp) static void riscv_cpu_satp_mode_finalize(RISCVCPU *cpu, Error **errp) { bool rv32 =3D riscv_cpu_mxl(&cpu->env) =3D=3D MXL_RV32; - uint8_t satp_mode_map_max; - uint8_t satp_mode_supported_max =3D - satp_mode_max_from_map(cpu->cfg.satp_mode.supporte= d); + uint8_t satp_mode_map_max, satp_mode_supported_max; + + /* The CPU wants the OS to decide which satp mode to use */ + if (cpu->cfg.satp_mode.supported =3D=3D 0) { + return; + } + + satp_mode_supported_max =3D + satp_mode_max_from_map(cpu->cfg.satp_mode.supported); =20 if (cpu->cfg.satp_mode.map =3D=3D 0) { if (cpu->cfg.satp_mode.init =3D=3D 0) { --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153465; cv=none; d=zohomail.com; s=zohoarc; b=WRq/5+1eBSK/pIf7Fij8DS9pHbT239mfOV12XV+TgpLa4es08vXJGd47aahDKgGv9rjsGxnAnCBo/8RwyFQBK+bdux1mgiesosEFbU98DQyt1bX6zO0qiv7C/rFhBmLiA5HXwg3aEezm8N2BcDEgBd7/PqlYHrRoSmTAuJ16gLE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153465; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SNW/cl5XE7PcFPCSWK9aTBzwWg07OvJep7oqCwyWKIs=; b=eCBuErhM26/tZ1ZH5/YvLXuhaNADj7kpMRtF4rhpWrbemV17HzPb2DjfKONF41O6E3rF62yqXEWwk/n7dmepMI1CGfVlJGwKQhYS2O6YtxVxk8H7CrMGViy5zen4RmiPhQATHjmk+2flK8x7hetItIHlYXXd6vW0XWC5HHO2Gls= 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 1694153465754727.6463414952871; Thu, 7 Sep 2023 23:11:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUeJ-00065r-M4; Fri, 08 Sep 2023 02:07:23 -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 1qeUeH-00062C-RH for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:21 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUeE-0007I1-J1 for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:21 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1c336f3f449so14699345ad.3 for ; Thu, 07 Sep 2023 23:07:18 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.07.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:07:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153237; x=1694758037; 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=SNW/cl5XE7PcFPCSWK9aTBzwWg07OvJep7oqCwyWKIs=; b=MD5v1ttUQBo6HfEnPmZLc9v2KX4HkTva+5CSvT8Y/tIuLdeFApMkWafaVz6QUpSXJZ RXy5DXAj2ybUNDjC1wBWfwLXbDUrw+PJkWOZHJVfPNjaIGzw0dkgQbt0dvMPeUDqAF2K Vvb89dKh/ydm7n4zyjlFtdOwmJ2K1nAGEuxYHr9Qf3aIftX1yrhLbF/FX6Nl9VYP+M5q KYfMrq1rBb/JcA+LcCvOlgO+jCIScCULl9LElIVDenCXrDH5Kfh5IqLETXmSlD1pT/O2 ccXOsfqjDSSqtx3Au9mrGT70Y6w+aD7aAmAquq8J9cQ4ihSGiHEyne1diN0m1ctirCNe UmXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153237; x=1694758037; 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=SNW/cl5XE7PcFPCSWK9aTBzwWg07OvJep7oqCwyWKIs=; b=Jvb/6hMOnCq69EA1nCRplgKfL9eT033X3uAVfL+x9yBDqs+aS6DCzwvvz1YVJKRIYO cKJrheS+JvV7nzA+HIyL/JX2KA4Qyl0aMSEytSa25Cbe1Ox9OXmuvEjoCi+7vFFW3D4T +1sdlfP47qc8bMST7z5oInTiOspSxs+TqgBR6feAznQtydUSu30posLxlh1hDQvKsfHt vbyrmgh7hwdyent0uEcE/f9fBrWlNb+aJc0e8E6r1U42wXF8gNZ38u1wl6JcX7hcQYy0 UcpGdac2R0gLnlcp0sTe5Xay9nWSu16rfpy82tzqDX1cHb9I7glo0jzADwHfTgLWGOvg B6Fg== X-Gm-Message-State: AOJu0YxZ541kt7KwbKR/soPMabcz+GDcsh0362CTwgD/WIpxhG1Q1QBv BG3A53E1AOz4eU/9MjE2toVpjxDeaBm3lq5V X-Google-Smtp-Source: AGHT+IFTrO40rcArjfhnK2w23VzZ2CJxt8XlylmyXhm5mz6WUotek8zR6/jdinwPsKvf9FHazhA14w== X-Received: by 2002:a17:902:d2d1:b0:1bd:c6ca:e0db with SMTP id n17-20020a170902d2d100b001bdc6cae0dbmr1711028plc.37.1694153236927; Thu, 07 Sep 2023 23:07:16 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Vineet Gupta , Alistair Francis Subject: [PULL 37/65] riscv: zicond: make non-experimental Date: Fri, 8 Sep 2023 16:04:03 +1000 Message-ID: <20230908060431.1903919-38-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::636; envelope-from=alistair23@gmail.com; helo=mail-pl1-x636.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: 1694153466629100001 Content-Type: text/plain; charset="utf-8" From: Vineet Gupta zicond is now codegen supported in both llvm and gcc. This change allows seamless enabling/testing of zicond in downstream projects. e.g. currently riscv-gnu-toolchain parses elf attributes to create a cmdline for qemu but fails short of enabling it because of the "x-" prefix. Signed-off-by: Vineet Gupta Message-ID: <20230808181715.436395-1-vineetg@rivosinc.com> Reviewed-by: Alistair Francis Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 34ac26e3ae..bf0912014e 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1869,6 +1869,7 @@ static Property riscv_cpu_extensions[] =3D { DEFINE_PROP_BOOL("zcf", RISCVCPU, cfg.ext_zcf, false), DEFINE_PROP_BOOL("zcmp", RISCVCPU, cfg.ext_zcmp, false), DEFINE_PROP_BOOL("zcmt", RISCVCPU, cfg.ext_zcmt, false), + DEFINE_PROP_BOOL("zicond", RISCVCPU, cfg.ext_zicond, false), =20 /* Vendor-specific custom extensions */ DEFINE_PROP_BOOL("xtheadba", RISCVCPU, cfg.ext_xtheadba, false), @@ -1885,7 +1886,6 @@ static Property riscv_cpu_extensions[] =3D { DEFINE_PROP_BOOL("xventanacondops", RISCVCPU, cfg.ext_XVentanaCondOps,= false), =20 /* These are experimental so mark with 'x-' */ - DEFINE_PROP_BOOL("x-zicond", RISCVCPU, cfg.ext_zicond, false), =20 /* ePMP 0.9.3 */ DEFINE_PROP_BOOL("x-epmp", RISCVCPU, cfg.epmp, false), --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153272; cv=none; d=zohomail.com; s=zohoarc; b=GcFVwEXS11Y+Ly/MPDlwmMzRlt9T0uuo0P2/H8o89cvR/yTtgLWZ97Ptjgl3kB5wxnHxJSqpUv/kLIUQq9IgxR/4MwDXarpDiuYCFM8rK8/rL0w8ZeFxCKlX6a+D2WltPfgvMIyuAY5sa4fNLxhm92Efo/minZkJCPi7wS6wGEk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153272; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NjXuICcOeuQWR8Rareoyy0vJVSEo7Ycr9iahUIb1+bw=; b=i3+n1KJWGDagNWqTvkax0dWutVPyVPx1TUGPaZz8QEpgkR3q8uRusQgo8ZlUbi/Cz5eZLHR28DNTjTD2HO24yRgUgI6hEX8zqZs0dUHlnK+P6J6f0MWl+ZiDPpaQbwBkhYvvoJqVn5y4ctot67Dsuj00Mj9LSh4i/7MHA+4eMLI= 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 1694153272594641.4124486901205; Thu, 7 Sep 2023 23:07:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUeP-0006r8-QW; Fri, 08 Sep 2023 02:07:30 -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 1qeUeN-0006X7-BT for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:27 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUeJ-0007Ox-Nq for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:26 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1c1e3a4a06fso13421655ad.3 for ; Thu, 07 Sep 2023 23:07:23 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.07.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:07:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153241; x=1694758041; 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=NjXuICcOeuQWR8Rareoyy0vJVSEo7Ycr9iahUIb1+bw=; b=OKaUSPZVxOVjChffvAp2R7K5mb3y1Fe1ehAHLjZZGkATVVy2KFHmiX0JtpFkfrqFK3 2dSBdbLrO0Zd+xwz3MV70twvqKYP3kmPFWkWqTGRUW9xE9+vfmzXaACFiw53mueburMT C7aEpatmMX3ysszpwwS3VHHpVYKk3UA9+zLlOhokQPbx1YQCLlv4N8xWmw2czarj3F5N OMHOprzDJkgtqjS04voV8l4j2mKfjxiOtRS93tPyREyjXJ4cZxOrDlZHGPgIEKkob4AI OL8lv35Zs41NjIdqgu2/NtNHzOo3CjQ4SS5HWiPaXV4zEy6C40F4HIR5Ly157SloOPsk Vmbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153241; x=1694758041; 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=NjXuICcOeuQWR8Rareoyy0vJVSEo7Ycr9iahUIb1+bw=; b=VUqA4cvudk/kJL6Dz4ZLir4nLLyBeBoIi2eAzjMNOWJ1udoTWWc/ytOnoBly4PTUp/ 9Yq8WXnM+/uU+HiVM9ZtCPbwFV6EzLVKrXo82Tay7aVhIHs1fGXfrhrAgohXIDJDHZdR TV/sMbaIugHRI91WiwJXx87LysMI8FL57lXQClA9vCppjsWrF0jBFKKNuBLCwtEORvR+ 4T1TgxWuhyoF7MjQInrf/MQDYttkSK2nO9QSo907DzZjLjOfPwuRotwCjkIgWNKWRext QhsZtVSk2D+YTs+TqcqDmqVz9oKE9LaagHaU6qZqPxv8Cg3LeORviEUgyCydNJrZv2Kq b9ZQ== X-Gm-Message-State: AOJu0YyBD+6VsyqRHnlB9fdkQ9bPH8GNRZsB+hbA3TwH6xTIMJ+Shg7V DDk7m0YJvMSvdDyXXj38omwoiOKTL2tuHukR X-Google-Smtp-Source: AGHT+IEWeqLfbC/iFt8+sn3sKJ609TC3/jJYop1v8tnraZ8coLpOqozUbcp9tW66H183m7c3srtCKQ== X-Received: by 2002:a17:903:495:b0:1c3:308b:ecb9 with SMTP id jj21-20020a170903049500b001c3308becb9mr1563699plb.11.1694153240833; Thu, 07 Sep 2023 23:07:20 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Richard Henderson , Andrew Jones , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Alistair Francis Subject: [PULL 38/65] hw/riscv/virt.c: fix non-KVM --enable-debug build Date: Fri, 8 Sep 2023 16:04:04 +1000 Message-ID: <20230908060431.1903919-39-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::62e; envelope-from=alistair23@gmail.com; helo=mail-pl1-x62e.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: 1694153273636100001 From: Daniel Henrique Barboza A build with --enable-debug and without KVM will fail as follows: /usr/bin/ld: libqemu-riscv64-softmmu.fa.p/hw_riscv_virt.c.o: in function `v= irt_machine_init': ./qemu/build/../hw/riscv/virt.c:1465: undefined reference to `kvm_riscv_aia= _create' This happens because the code block with "if virt_use_kvm_aia(s)" isn't being ignored by the debug build, resulting in an undefined reference to a KVM only function. Add a 'kvm_enabled()' conditional together with virt_use_kvm_aia() will make the compiler crop the kvm_riscv_aia_create() call entirely from a non-KVM build. Note that adding the 'kvm_enabled()' conditional inside virt_use_kvm_aia() won't fix the build because this function would need to be inlined multiple times to make the compiler zero out the entire block. While we're at it, use kvm_enabled() in all instances where virt_use_kvm_aia() is checked to allow the compiler to elide these other kvm-only instances as well. Suggested-by: Richard Henderson Fixes: dbdb99948e ("target/riscv: select KVM AIA in riscv virt machine") Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Message-ID: <20230830133503.711138-2-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- hw/riscv/virt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 388e52a294..3b259b9305 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -782,7 +782,7 @@ static void create_fdt_sockets(RISCVVirtState *s, const= MemMapEntry *memmap, } =20 /* KVM AIA only has one APLIC instance */ - if (virt_use_kvm_aia(s)) { + if (kvm_enabled() && virt_use_kvm_aia(s)) { create_fdt_socket_aplic(s, memmap, 0, msi_m_phandle, msi_s_phandle, phandle, &intc_phandles[0], xplic_phandles, @@ -808,7 +808,7 @@ static void create_fdt_sockets(RISCVVirtState *s, const= MemMapEntry *memmap, =20 g_free(intc_phandles); =20 - if (virt_use_kvm_aia(s)) { + if (kvm_enabled() && virt_use_kvm_aia(s)) { *irq_mmio_phandle =3D xplic_phandles[0]; *irq_virtio_phandle =3D xplic_phandles[0]; *irq_pcie_phandle =3D xplic_phandles[0]; @@ -1461,7 +1461,7 @@ static void virt_machine_init(MachineState *machine) } } =20 - if (virt_use_kvm_aia(s)) { + if (kvm_enabled() && virt_use_kvm_aia(s)) { kvm_riscv_aia_create(machine, IMSIC_MMIO_GROUP_MIN_SHIFT, VIRT_IRQCHIP_NUM_SOURCES, VIRT_IRQCHIP_NUM_MS= IS, memmap[VIRT_APLIC_S].base, --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153288; cv=none; d=zohomail.com; s=zohoarc; b=Bq3tO9jD6Y3QnDRqKnYE8n5G+V/TgREdGUnw883vL7lZYvDJN+kRhMQXA16gOG4ANMJlYz/4J4XSIUUbZCE7txgWsUvhs13gkYVyPznMjEavGc3rb9nCN4n6NpNrR/qTxwacQmp2HYomj0MDWY9uo1Ib/dg0b09ZArdJZhGysw0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153288; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZSYhbUljQLmwwhGQ4cyo7MT1zkKpeBlZTKYRcuPWFf8=; b=lZP2HlhnbAW2Y84cTPMkHmoti69bI2cW/k9ZdC/84cGfs1OGw45/jtUT4dti9OJHnNpz7S5lrxVhsfsQK2hdiWRFpWpW4DIVQyfaVchZmbZdxJitocsvyM/drwg5CEk6uMRx3AQKbhE18/7Kmhl9O9HgU/L5hrbDsZVGqO+L8qs= 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 1694153288697282.1028596889539; Thu, 7 Sep 2023 23:08:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUeb-00087x-38; Fri, 08 Sep 2023 02:07:41 -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 1qeUeY-0007qr-1W for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:38 -0400 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 1qeUeM-0007WZ-LQ for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:37 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1bdbf10333bso14066755ad.1 for ; Thu, 07 Sep 2023 23:07:26 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.07.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:07:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153245; x=1694758045; 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=ZSYhbUljQLmwwhGQ4cyo7MT1zkKpeBlZTKYRcuPWFf8=; b=JQgewvFVTAaBmeJjF5B5mzBOF8UfK7CPvy6P9XhfB0shsWlx3Q6S/E+1B4vN3slcj+ RHNS2OGQ6LQnU0uG9DLvzovkHuQ+IUZo+LSRzNSdgsG/jkhA4NLcLuBOUVoyVfcJuUyM Vh0iQGolUP19yf0tE9OzUwBPAkAnMdydclzfkncqgmnw41PKF3h1OkZTMv6zlsS3tCxx /91RA+qyHNuhZGGEc4BEhuxGTUgy9Rmr9EFOpKdoCVxNUm5NApX4aL2YRXvKptzXYKNM MigujSTlO2uq8zdFudmZUMqEq5fEpAFA+pRmzgVyYIlJaIYh3yyo/zEXoJS/IvFKFKUp 2E7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153245; x=1694758045; 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=ZSYhbUljQLmwwhGQ4cyo7MT1zkKpeBlZTKYRcuPWFf8=; b=kXErJeOxjPUljpkXwJ6iV7sIZlIpp+4KIV8bZ6ffwU6sZ15/W/6ywAi9NOut580DW5 2YkTirJpTriXCerkR7j+3yePs44HfZxIrGgb07+zkQ4nTiktnROWHjwcNRxHAy7QURNV HlTccdbHzlymHQ3bwY7N4FYMLz6Gu3UsRxzQAnwTDxXtw733LKmcdDwZqeeuVlk+Z9w4 lPj/LSpXAfRqWW+TL1ZtYmuT9ZZ4OL5IhyUoKIBAtLiat6jLj+27SkwDUN879v0qsPiW KFuDvnpfBPQkqI45msQvq4YD+fKuLF5pIr23wgH1an0BlGmZ6iAD3B+pT6OlW/S6WSJ/ fM+g== X-Gm-Message-State: AOJu0Yx9dNoTw8Rxl8Z7FMcKKfz7rAo0YgdT8dZfI//LWXPw7vMj+JcU cRT116Qlh7UKZX0rzLCIgWKEFq136J9cxa+q X-Google-Smtp-Source: AGHT+IEevPaL7hfRFmVfQ1ZyULUnjOfDZO7RDXIgYD4mqcpW5HEHKvToSWUTm+R0YSmYjjyKQZDvjg== X-Received: by 2002:a17:903:48d:b0:1b8:987f:3f34 with SMTP id jj13-20020a170903048d00b001b8987f3f34mr1633063plb.25.1694153244879; Thu, 07 Sep 2023 23:07:24 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Andrew Jones , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Alistair Francis Subject: [PULL 39/65] hw/intc/riscv_aplic.c fix non-KVM --enable-debug build Date: Fri, 8 Sep 2023 16:04:05 +1000 Message-ID: <20230908060431.1903919-40-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=alistair23@gmail.com; helo=mail-pl1-x62f.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, 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: 1694153290700100005 From: Daniel Henrique Barboza Commit 6df0b37e2ab breaks a --enable-debug build in a non-KVM environment with the following error: /usr/bin/ld: libqemu-riscv64-softmmu.fa.p/hw_intc_riscv_aplic.c.o: in funct= ion `riscv_kvm_aplic_request': ./qemu/build/../hw/intc/riscv_aplic.c:486: undefined reference to `kvm_set_= irq' collect2: error: ld returned 1 exit status This happens because the debug build will poke into the 'if (is_kvm_aia(aplic->msimode))' block and fail to find a reference to the KVM only function riscv_kvm_aplic_request(). There are multiple solutions to fix this. We'll go with the same solution from the previous patch, i.e. add a kvm_enabled() conditional to filter out the block. But there's a catch: riscv_kvm_aplic_request() is a local function that would end up being used if the compiler crops the block, and this won't work. Quoting Richard Henderson's explanation in [1]: "(...) the compiler won't eliminate entire unused functions with -O0" We'll solve it by moving riscv_kvm_aplic_request() to kvm.c and add its declaration in kvm_riscv.h, where all other KVM specific public functions are already declared. Other archs handles KVM specific code in this manner and we expect to do the same from now on. [1] https://lore.kernel.org/qemu-riscv/d2f1ad02-eb03-138f-9d08-db676deeed05= @linaro.org/ Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Message-ID: <20230830133503.711138-3-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/kvm_riscv.h | 1 + hw/intc/riscv_aplic.c | 8 ++------ target/riscv/kvm.c | 5 +++++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/target/riscv/kvm_riscv.h b/target/riscv/kvm_riscv.h index 7d4b7c60e2..de8c209ebc 100644 --- a/target/riscv/kvm_riscv.h +++ b/target/riscv/kvm_riscv.h @@ -26,5 +26,6 @@ void kvm_riscv_aia_create(MachineState *machine, uint64_t= group_shift, uint64_t aia_irq_num, uint64_t aia_msi_num, uint64_t aplic_base, uint64_t imsic_base, uint64_t guest_num); +void riscv_kvm_aplic_request(void *opaque, int irq, int level); =20 #endif diff --git a/hw/intc/riscv_aplic.c b/hw/intc/riscv_aplic.c index 592c3ce768..99aae8ccbe 100644 --- a/hw/intc/riscv_aplic.c +++ b/hw/intc/riscv_aplic.c @@ -32,6 +32,7 @@ #include "target/riscv/cpu.h" #include "sysemu/sysemu.h" #include "sysemu/kvm.h" +#include "kvm_riscv.h" #include "migration/vmstate.h" =20 #define APLIC_MAX_IDC (1UL << 14) @@ -481,11 +482,6 @@ static uint32_t riscv_aplic_idc_claimi(RISCVAPLICState= *aplic, uint32_t idc) return topi; } =20 -static void riscv_kvm_aplic_request(void *opaque, int irq, int level) -{ - kvm_set_irq(kvm_state, irq, !!level); -} - static void riscv_aplic_request(void *opaque, int irq, int level) { bool update =3D false; @@ -840,7 +836,7 @@ static void riscv_aplic_realize(DeviceState *dev, Error= **errp) * have IRQ lines delegated by their parent APLIC. */ if (!aplic->parent) { - if (is_kvm_aia(aplic->msimode)) { + if (kvm_enabled() && is_kvm_aia(aplic->msimode)) { qdev_init_gpio_in(dev, riscv_kvm_aplic_request, aplic->num_irq= s); } else { qdev_init_gpio_in(dev, riscv_aplic_request, aplic->num_irqs); diff --git a/target/riscv/kvm.c b/target/riscv/kvm.c index 6e909d0fdd..c01cfb03f4 100644 --- a/target/riscv/kvm.c +++ b/target/riscv/kvm.c @@ -46,6 +46,11 @@ #include "sysemu/runstate.h" #include "hw/riscv/numa.h" =20 +void riscv_kvm_aplic_request(void *opaque, int irq, int level) +{ + kvm_set_irq(kvm_state, irq, !!level); +} + static uint64_t kvm_riscv_reg_id(CPURISCVState *env, uint64_t type, uint64_t idx) { --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153676; cv=none; d=zohomail.com; s=zohoarc; b=aDVaQn4kc1JuPD8Qh83F5fzU7+dudpyFc+/clsnFBmAPtE2akT6CJoODL/iZ33QsICayqsEwdn/GnOTsrwzZ2ZOCD8l5KUIGOPeKlSsV2IH8yKmJ4tPegDtgFtQ/WSBp0HvkkkVaVdvHI3Xof6Vp/A38h5QoBUw+q/qoBjJBpq4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153676; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BNko/n7sZ+Pauuo1Y0kdsEEem9IIq4A/xXv8veLPZZU=; b=RSZLRHuxASZQ64YIl9tFZqARDNzxG6JL4X9lXkimRT9WJEDkVVYZwauLVuyUQfAbKzJk70HwCYDl6anzJ77pGSK3UnVpnltIsqPUnOTFCTetUjvSAoArLO7MwMBWbbSwSkFItqfKWsbxpJ4hUOs0Jd4NCo6dz40WFir9pQuyKB0= 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 1694153676570584.8190376004234; Thu, 7 Sep 2023 23:14:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUec-0008Ga-St; Fri, 08 Sep 2023 02:07:42 -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 1qeUea-00083B-2a for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:41 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUeQ-0007gl-67 for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:39 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1bdc19b782aso13625395ad.0 for ; Thu, 07 Sep 2023 23:07:29 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.07.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:07:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153248; x=1694758048; 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=BNko/n7sZ+Pauuo1Y0kdsEEem9IIq4A/xXv8veLPZZU=; b=ru7QXXje3TO7Invb/34bDMr8FvB3V42QYcAl8VoKg2XcSPeyVSn9zc2Op6Ow8StnfH T9Eia3O/nEDiYooAAQpsBO2C7l0gm3Jru6nEW1lGu2va6rc/OqOv/rwvXSd1rlaz+KzL I9AufhPaGUEeeu5Bjf68Kt8kLGS1Y+e5eOmuD1cRTkmpEy7+6fj6bhaG/MUfvg3ioIWo CqCU6SF6dBRS/eolB+bbB/RWY1civWznPpoc+//KGqLmrryFliEoeP0UFUX8SjF+xWEY LAw/C3B4APBkW3oxldRJ0M1y0aDun8CxAwQaMHG+UfaptZ6FHkzBeJLGQXhRAg1XP0xq KvPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153248; x=1694758048; 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=BNko/n7sZ+Pauuo1Y0kdsEEem9IIq4A/xXv8veLPZZU=; b=A8wZUpU/p2xlCKx6QSCcDQseVuNWdmEQwOZ5fQN5L8TfjNdgZJMetFjvNHkOi0YHeo HV+J/NlvB/4Xy60FDLJzdSFRUUdVr3rYqt9HBZieQpHBssh7lobM/2eDg0rs7Ji2E58K l2G+JiMqHFJZ4CCSx9poWHDZ4LzaUeX4683cXrXh1osTMSN+joP7g8tzzVBZmyU8h3jC 7Am2QBvkaHM/Rim3nS9ugL6SZA41R8So2Kblp1uqr5N1HRXneLMErYvqmrEiFDLYl939 KqpPq6r32UVDWd2VlV7ZRE/95/Y2BqXiZ9hpB23My2tyDN/h8nx3x9ik9QGtuCaz70JR DY3Q== X-Gm-Message-State: AOJu0YwLuoxUbhie9bnqk3r7tYr7L0iy5edCPRF0J7W2mlBWlMcBpQfB KPXiSvcBvTzemfNGTUjt4I6u1BaIJxpjYCGp X-Google-Smtp-Source: AGHT+IF+ctQ8LOrwMOuhn33LtjrZEYHZwQzW6W/JQ0wnXRQE/7TDhMnxRmHK+UmbGp7mbxPc2/MYYg== X-Received: by 2002:a17:902:da92:b0:1b6:6b90:7c2f with SMTP id j18-20020a170902da9200b001b66b907c2fmr1685214plx.55.1694153248577; Thu, 07 Sep 2023 23:07:28 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Robbin Ehn , Richard Henderson , Alistair Francis Subject: [PULL 40/65] linux-user/riscv: Add new extensions to hwprobe Date: Fri, 8 Sep 2023 16:04:06 +1000 Message-ID: <20230908060431.1903919-41-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::62e; envelope-from=alistair23@gmail.com; helo=mail-pl1-x62e.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: 1694153677708100001 Content-Type: text/plain; charset="utf-8" From: Robbin Ehn This patch adds the new extensions in linux 6.5 to the hwprobe syscall. And fixes RVC check to OR with correct value. The previous variable contains 0 therefore it did work. Signed-off-by: Robbin Ehn Acked-by: Richard Henderson Acked-by: Alistair Francis Message-ID: Signed-off-by: Alistair Francis --- linux-user/syscall.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index dac0641bab..3521a2d70b 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8793,6 +8793,10 @@ static int do_getdents64(abi_long dirfd, abi_long ar= g2, abi_long count) #define RISCV_HWPROBE_KEY_IMA_EXT_0 4 #define RISCV_HWPROBE_IMA_FD (1 << 0) #define RISCV_HWPROBE_IMA_C (1 << 1) +#define RISCV_HWPROBE_IMA_V (1 << 2) +#define RISCV_HWPROBE_EXT_ZBA (1 << 3) +#define RISCV_HWPROBE_EXT_ZBB (1 << 4) +#define RISCV_HWPROBE_EXT_ZBS (1 << 5) =20 #define RISCV_HWPROBE_KEY_CPUPERF_0 5 #define RISCV_HWPROBE_MISALIGNED_UNKNOWN (0 << 0) @@ -8840,7 +8844,15 @@ static void risc_hwprobe_fill_pairs(CPURISCVState *e= nv, riscv_has_ext(env, RVD) ? RISCV_HWPROBE_IMA_FD : 0; value |=3D riscv_has_ext(env, RVC) ? - RISCV_HWPROBE_IMA_C : pair->value; + RISCV_HWPROBE_IMA_C : 0; + value |=3D riscv_has_ext(env, RVV) ? + RISCV_HWPROBE_IMA_V : 0; + value |=3D cfg->ext_zba ? + RISCV_HWPROBE_EXT_ZBA : 0; + value |=3D cfg->ext_zbb ? + RISCV_HWPROBE_EXT_ZBB : 0; + value |=3D cfg->ext_zbs ? + RISCV_HWPROBE_EXT_ZBS : 0; __put_user(value, &pair->value); break; case RISCV_HWPROBE_KEY_CPUPERF_0: --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153667; cv=none; d=zohomail.com; s=zohoarc; b=eHFaPPUSPmnnIXlFYufJd5dmmZhBVKKFdJScKt27+PPng+OuMmj7F36D7FioOLvPKcQp1dmBJ/1Zj2kpFUXMOigKxcCBTV7SbonKGplKprlrLnn3Ul3a/Sec1syWU4f4h9wvInPwf3hhKkhL2snZQmMt6QgwPUJ1QxeRnIzVUhs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153667; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sm5kdR4zPqERpHwNfrDrMNoNCsEGBcjXZveAeFuP0TY=; b=F7YRwnDafHj4T5ss6CyT8fUQE2WwFR1tRGmPW/AYAAylox+8cJlGb1gUNdSz120uvw+CCW4BXJbGm1tSvH/0zANKvzvzIjC2SHQM2rFtpZpNH/t+JxinqLgWf0TyigqpfaygdVBcS7BBvWZJhlXj2Os5dJHNvaMQAPS5NWpPBMo= 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 1694153667034618.3497802593286; Thu, 7 Sep 2023 23:14:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUed-0008IL-63; Fri, 08 Sep 2023 02:07:43 -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 1qeUeb-000891-D3 for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:41 -0400 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 1qeUeV-0007p5-NO for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:40 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1c0db66af1bso12627095ad.2 for ; Thu, 07 Sep 2023 23:07:35 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.07.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:07:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153253; x=1694758053; 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=sm5kdR4zPqERpHwNfrDrMNoNCsEGBcjXZveAeFuP0TY=; b=sqGmyToYWjbr7YcKfKgBYVl0VBtkPFsKrX1MrtQCPovpVenDJGjfLwJoVmgYq5eFcC W9nrm2NadyL7HG9sQaAbUaLNBvZtBES/dpZ6cKbhXWmHY1TRmqMiN25fgyLy6YGWxsVS 6AcImHUOEcTfNIiotyosOQGxTjI/Yxa3BzNHsapt5BdxJFlPIwu72SLmJQuXj3ApiOGS ujh7q27Vk97ABqFNixmxWU+Yzdv8QStvDuBqVAUrTZgVmtMIIDOFIhlPINgLagwn8xvt kobgcjnGjQDZaZM6QKlFol/rigUvOcz5Ao7dkNqS3invd3bxAxLphoP1ybVsIUO7Fhb3 osVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153253; x=1694758053; 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=sm5kdR4zPqERpHwNfrDrMNoNCsEGBcjXZveAeFuP0TY=; b=enZNsMrFeDngow2/RZWp9kMYoPpEcfgW59V7bKlcR5WqoDILFJO9o7CyDfI1XD3mM4 /efbtwxVXF/iWsiPw6V+SoB0gQOSMD3XNM+YwUVkFbWJqJjEhodd4FvuClaKzPbMXDzB cfts4facvHCleOHwa4TygvT12Pjd1eZILHQVD7igIcVHoeUhy3nnbT7z1SFh4wyGAbfo rw+eKPIkscgVi6CHMo1E9UJisStb3BmEsnvgRvR3TI/6wMH0NYq5rY4V5VvbncSomXPi 5SIYn9L8Q7efE0OmaC2m7XDz1N5bnEYhT0PGUbUjucAqY47yNPLP36m0P3PvfC4JWOvV USVQ== X-Gm-Message-State: AOJu0YxWxjya+8HNhMwS5c9jtaECB01ZoEInyEAQLb36TSd7GS2Ahw2G v0YNXKJpN6BhqyB6wRF3eduzZWcZhw7kqs40 X-Google-Smtp-Source: AGHT+IF4iDlPLdiu4Jcis6dnXVE5fmlBYh0DPyl7ZdL15Xkz/OFXXG/E7jxXFh9Q56bRVxZA+88kew== X-Received: by 2002:a17:902:f7c7:b0:1b8:7fd7:e022 with SMTP id h7-20020a170902f7c700b001b87fd7e022mr1737965plw.28.1694153252826; Thu, 07 Sep 2023 23:07:32 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Ard Biesheuvel , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Palmer Dabbelt , Alistair Francis Subject: [PULL 41/65] target/riscv: Use accelerated helper for AES64KS1I Date: Fri, 8 Sep 2023 16:04:07 +1000 Message-ID: <20230908060431.1903919-42-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=alistair23@gmail.com; helo=mail-pl1-x634.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: 1694153669459100019 From: Ard Biesheuvel Use the accelerated SubBytes/ShiftRows/AddRoundKey AES helper to implement the first half of the key schedule derivation. This does not actually involve shifting rows, so clone the same value into all four columns of the AES vector to counter that operation. Cc: Richard Henderson Cc: Philippe Mathieu-Daud=C3=A9 Cc: Palmer Dabbelt Cc: Alistair Francis Signed-off-by: Ard Biesheuvel Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Message-ID: <20230831154118.138727-1-ardb@kernel.org> Signed-off-by: Alistair Francis --- target/riscv/crypto_helper.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/target/riscv/crypto_helper.c b/target/riscv/crypto_helper.c index 4d65945429..bb084e00ef 100644 --- a/target/riscv/crypto_helper.c +++ b/target/riscv/crypto_helper.c @@ -148,24 +148,17 @@ target_ulong HELPER(aes64ks1i)(target_ulong rs1, targ= et_ulong rnum) =20 uint8_t enc_rnum =3D rnum; uint32_t temp =3D (RS1 >> 32) & 0xFFFFFFFF; - uint8_t rcon_ =3D 0; - target_ulong result; + AESState t, rc =3D {}; =20 if (enc_rnum !=3D 0xA) { temp =3D ror32(temp, 8); /* Rotate right by 8 */ - rcon_ =3D round_consts[enc_rnum]; + rc.w[0] =3D rc.w[1] =3D round_consts[enc_rnum]; } =20 - temp =3D ((uint32_t)AES_sbox[(temp >> 24) & 0xFF] << 24) | - ((uint32_t)AES_sbox[(temp >> 16) & 0xFF] << 16) | - ((uint32_t)AES_sbox[(temp >> 8) & 0xFF] << 8) | - ((uint32_t)AES_sbox[(temp >> 0) & 0xFF] << 0); + t.w[0] =3D t.w[1] =3D t.w[2] =3D t.w[3] =3D temp; + aesenc_SB_SR_AK(&t, &t, &rc, false); =20 - temp ^=3D rcon_; - - result =3D ((uint64_t)temp << 32) | temp; - - return result; + return t.d[0]; } =20 target_ulong HELPER(aes64im)(target_ulong rs1) --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153574; cv=none; d=zohomail.com; s=zohoarc; b=EI6WHjnYgRHmqSR+y7KcJQeGqlyZVHdMwj214Oo7tdXuPgQlSGS5l0sF+bXqqEC3E0yGv+FgoXzDLsj0qQZLKJHs6UM6/6NyYaiya0KDTNQ7xx6uKF6s7h9Gk4oG5WmrFWg94Ihaz2TzSu2d086JL6Ex6doZPR6TewRChG0BazY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153574; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9BtKiY4lAmSAzTij8lSOcl0A+RCHDkyDwuH2ARMSmck=; b=WZbv59Sy7TZ+k6r7hTqafYB4EJJxem+/x2IedzduyOVeoZVWVFT9hMR9N1eEGVShPsk5A0UZq/AzG9VtYulrmztGMuVCNUD1eM5143qvhHOXBDkON93H1JMpOGKoeE3MvJxUWk5/88xZ8VisjccmDmM4pCxVRuiMkgVA4qOQljw= 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 1694153574222168.18919944667402; Thu, 7 Sep 2023 23:12:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUed-0008Pg-PJ; Fri, 08 Sep 2023 02:07:43 -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 1qeUec-0008EB-8Q for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:42 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUeY-0007wt-Lt for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:41 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1bf078d5f33so15458095ad.3 for ; Thu, 07 Sep 2023 23:07:38 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.07.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:07:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153257; x=1694758057; 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=9BtKiY4lAmSAzTij8lSOcl0A+RCHDkyDwuH2ARMSmck=; b=bRSXjN5KHIptPtcEarMuQhMarGF2qwUbjrIBzBrtP6R//iHbIrLDXs9a8ZZ0Ue085O cxv3Q6uCa1i+c3LC+5rzIR1+sFjMgH3BXd7DATocaG+5Vu3aYno5vr/GvlR0VNbpgs8U KUE/FGdpcvEinbIwGFz9iqwXveBWHxvlGvEhJ/olMm+LsLDy439KJNXPnMLha+ir8Goi mvCV+HR2+iukt5lks/cCA92VkD29ikEUMh7Ee2Ej9WlEYg2+SGwysK4vZE9J+0190gfc rn0ZBBKh8Q+o3ZMux/odpaxq4IppDVVVrUS8phhvW/RJ5DCklv97R5xba4IB22iBLeOy nr+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153257; x=1694758057; 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=9BtKiY4lAmSAzTij8lSOcl0A+RCHDkyDwuH2ARMSmck=; b=DjTqVgiKiaLoTfcRYm2jmkpaeV3wBk9soAMUjVkbqc3wIzO91DS/Vn9nSqKh5O+M3g G1Nppz8hgf5Zewm8Gm1Er1SwbD6IxHX1i9jbMLMtOaJX9o9X0btCv0CZMkumf4ja48nJ WH7NgTFo7Z/IrJv6I7RtCr4XLHrbCKHv9CPG/lf/7dyQ9SebHXCMWKMk25nNQXnN00Sw xECnCT/hmiiy5IQGzpqyWComohygMtKzMgcYGWvgyUyXKUprCXYd0toNGz+RoP9djEO4 WyToi8fHkUD8HCtNgNgIfOZ3PtdZvNH4cvbv+KXgo6x+GJsQXCmjFppvgIgYpWYsF0LA QvHg== X-Gm-Message-State: AOJu0Yzozfi3EcVdq5LfGJ1AbCCXYFqr1aIxT38O7wc2o/czQ2iQc0WJ gNdCpGbhY6kHq/6Pw21NXZQVzPEcokMc4qxj X-Google-Smtp-Source: AGHT+IEtGzk3ZXoYBuFnVsCODJr5pbDWTseufTMVZosJwV2G0QWeUi0vA1Evs2kqndh+b+29oyiTBg== X-Received: by 2002:a17:902:74c8:b0:1c3:2ee6:3811 with SMTP id f8-20020a17090274c800b001c32ee63811mr1873587plt.8.1694153257034; Thu, 07 Sep 2023 23:07:37 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Akihiko Odaki , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , LIU Zhiwei , Alistair Francis Subject: [PULL 42/65] target/riscv: Allocate itrigger timers only once Date: Fri, 8 Sep 2023 16:04:08 +1000 Message-ID: <20230908060431.1903919-43-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::636; envelope-from=alistair23@gmail.com; helo=mail-pl1-x636.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: 1694153575065100001 From: Akihiko Odaki riscv_trigger_init() had been called on reset events that can happen several times for a CPU and it allocated timers for itrigger. If old timers were present, they were simply overwritten by the new timers, resulting in a memory leak. Divide riscv_trigger_init() into two functions, namely riscv_trigger_realize() and riscv_trigger_reset() and call them in appropriate timing. The timer allocation will happen only once for a CPU in riscv_trigger_realize(). Fixes: 5a4ae64cac ("target/riscv: Add itrigger support when icount is enabl= ed") Signed-off-by: Akihiko Odaki Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: LIU Zhiwei Reviewed-by: Alistair Francis Message-ID: <20230818034059.9146-1-akihiko.odaki@daynix.com> Signed-off-by: Alistair Francis --- target/riscv/debug.h | 3 ++- target/riscv/cpu.c | 8 +++++++- target/riscv/debug.c | 15 ++++++++++++--- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/target/riscv/debug.h b/target/riscv/debug.h index c471748d5a..5794aa6ee5 100644 --- a/target/riscv/debug.h +++ b/target/riscv/debug.h @@ -143,7 +143,8 @@ void riscv_cpu_debug_excp_handler(CPUState *cs); bool riscv_cpu_debug_check_breakpoint(CPUState *cs); bool riscv_cpu_debug_check_watchpoint(CPUState *cs, CPUWatchpoint *wp); =20 -void riscv_trigger_init(CPURISCVState *env); +void riscv_trigger_realize(CPURISCVState *env); +void riscv_trigger_reset_hold(CPURISCVState *env); =20 bool riscv_itrigger_enabled(CPURISCVState *env); void riscv_itrigger_update_priv(CPURISCVState *env); diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index bf0912014e..f227c7664e 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -926,7 +926,7 @@ static void riscv_cpu_reset_hold(Object *obj) =20 #ifndef CONFIG_USER_ONLY if (cpu->cfg.debug) { - riscv_trigger_init(env); + riscv_trigger_reset_hold(env); } =20 if (kvm_enabled()) { @@ -1525,6 +1525,12 @@ static void riscv_cpu_realize(DeviceState *dev, Erro= r **errp) =20 riscv_cpu_register_gdb_regs_for_features(cs); =20 +#ifndef CONFIG_USER_ONLY + if (cpu->cfg.debug) { + riscv_trigger_realize(&cpu->env); + } +#endif + qemu_init_vcpu(cs); cpu_reset(cs); =20 diff --git a/target/riscv/debug.c b/target/riscv/debug.c index 75ee1c4971..ddd46b2d3e 100644 --- a/target/riscv/debug.c +++ b/target/riscv/debug.c @@ -903,7 +903,17 @@ bool riscv_cpu_debug_check_watchpoint(CPUState *cs, CP= UWatchpoint *wp) return false; } =20 -void riscv_trigger_init(CPURISCVState *env) +void riscv_trigger_realize(CPURISCVState *env) +{ + int i; + + for (i =3D 0; i < RV_MAX_TRIGGERS; i++) { + env->itrigger_timer[i] =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, + riscv_itrigger_timer_cb, env= ); + } +} + +void riscv_trigger_reset_hold(CPURISCVState *env) { target_ulong tdata1 =3D build_tdata1(env, TRIGGER_TYPE_AD_MATCH, 0, 0); int i; @@ -928,7 +938,6 @@ void riscv_trigger_init(CPURISCVState *env) env->tdata3[i] =3D 0; env->cpu_breakpoint[i] =3D NULL; env->cpu_watchpoint[i] =3D NULL; - env->itrigger_timer[i] =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, - riscv_itrigger_timer_cb, env= ); + timer_del(env->itrigger_timer[i]); } } --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153492; cv=none; d=zohomail.com; s=zohoarc; b=Kw9uN7NFHkQguKbyKGdPZlGA4Ab/sS8aS4hGjCKbwINOMPYX79KIZ3dIN3+1ADP2BPR8PBZc2eW9h0QNb2rd/0si7LH5Yiv+NHJ/5BNtenw2y9sEQVAEiZ7+HGIaxUmyfne7MiiD+AXsUzMP2Rt3iitTWySSdxKMvFKLJ45ayT8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153492; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0AugPxvR0Xk9MuYdUUIr4+5lfDeBI452w5K1Z6wU4Oo=; b=TrgJmmMJO28jSIf6btGY2CHSOVAspb4Qw5l+Ona81pSpgmvKrIYRE+T4EpYpns6EVW+byLhUmYNRD1VN2Qz0qgRMYkY7nJR48ABPJxCLpGjy20pAPofJtS9lWcZOhgDNOAZISxoSKDeI5xu6OiI82bP/DhOVtVFICVGpG7n0ZvY= 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 1694153492208321.7487753670696; Thu, 7 Sep 2023 23:11:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUeh-0000TV-6U; Fri, 08 Sep 2023 02:07:47 -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 1qeUee-0008UF-Hw for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:44 -0400 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 1qeUec-0007zg-4X for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:44 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1c0c6d4d650so14149045ad.0 for ; Thu, 07 Sep 2023 23:07:41 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.07.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:07:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153260; x=1694758060; 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=0AugPxvR0Xk9MuYdUUIr4+5lfDeBI452w5K1Z6wU4Oo=; b=Ydql29YjQnld/p7nog9v6agpIzrFmygCrSZ5M+h2C6znlOiPrh7aJ/ENzAsYKTIUqL YhmLEj5hstc7h2EbW9TNqGHIMVIghSfRx4I56xXb5iLPaJROS0TVVdwmExckXlpMjS0f D5v4nvKDuUBMy3cM762iprC/AMQ4iwhaVpgBrIK/T5Ho4sQGNTqcOd6+B4ae5i8XhuEO bJKA/Gz5Lk2lZuVFVsJc103JHDQuM51TMhEHBP8bp+70sFSX/NDPF9VxaZMlp+EB8gQu uocJo+DqiW/KpRhMo3y+5hFXf/QbIfGniJ3bP7dHNznIkwHNnDHNMuya+1VRhPH5A7f+ rRwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153260; x=1694758060; 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=0AugPxvR0Xk9MuYdUUIr4+5lfDeBI452w5K1Z6wU4Oo=; b=ibxwgO8TtJ70iESes7jdbKuqpTdYT3xeSyKEqn25gIHvqp6M/TpEF0bpsa3hXs6E8j +ke7/zocYT6kJ9SJnN7g/IO+YObViUFbTW+6PH9twWs+xZD8LNy3Ktwo/BRmN9FbQNZx 3BVvvBDiDv3nVeSLPeuuOvC+X+IoEyvneO8JGqB5cu6w6z1colKPeg71W97ZUX75n8m9 d+c/LfKLKTZRDN3atN2YcX547G0TVnMX90j+k76cFte6guVfZwTnCvmtypgQjd0gBTMe opqBe7Dui3sdO+LCyDyBbH90uIyyHR7KeiXn2xmE7LJc5oRFyMKKrR8tzuknprITche6 2U3w== X-Gm-Message-State: AOJu0YzRsgXJq/NBlZ8ygrABtsZMR4ADTKHQmSC9M5Udnu1RmVmTjjxo 53nfAfRR5EoFyI63NG3G0ZIfOww7i86+0bwW X-Google-Smtp-Source: AGHT+IGSO7zM7c1BH1Gmz9Rs7orb9gWeMyXJkjIauz96NMUNDqmJMcLpAcKRXSYdt3pNNV/VTBbGvA== X-Received: by 2002:a17:902:be16:b0:1bb:9f07:5e0 with SMTP id r22-20020a170902be1600b001bb9f0705e0mr1570284pls.60.1694153260474; Thu, 07 Sep 2023 23:07:40 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Leon Schuermann , Mayuresh Chitale , Alistair Francis Subject: [PULL 43/65] target/riscv/pmp.c: respect mseccfg.RLB for pmpaddrX changes Date: Fri, 8 Sep 2023 16:04:09 +1000 Message-ID: <20230908060431.1903919-44-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::62d; envelope-from=alistair23@gmail.com; helo=mail-pl1-x62d.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: 1694153493337100001 Content-Type: text/plain; charset="utf-8" From: Leon Schuermann When the rule-lock bypass (RLB) bit is set in the mseccfg CSR, the PMP configuration lock bits must not apply. While this behavior is implemented for the pmpcfgX CSRs, this bit is not respected for changes to the pmpaddrX CSRs. This patch ensures that pmpaddrX CSR writes work even on locked regions when the global rule-lock bypass is enabled. Signed-off-by: Leon Schuermann Reviewed-by: Mayuresh Chitale Reviewed-by: Alistair Francis Message-ID: <20230829215046.1430463-1-leon@is.currently.online> Signed-off-by: Alistair Francis --- target/riscv/pmp.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/riscv/pmp.c b/target/riscv/pmp.c index 9d8db493e6..5e60c26031 100644 --- a/target/riscv/pmp.c +++ b/target/riscv/pmp.c @@ -44,6 +44,10 @@ static inline uint8_t pmp_get_a_field(uint8_t cfg) */ static inline int pmp_is_locked(CPURISCVState *env, uint32_t pmp_index) { + /* mseccfg.RLB is set */ + if (MSECCFG_RLB_ISSET(env)) { + return 0; + } =20 if (env->pmp_state.pmp[pmp_index].cfg_reg & PMP_LOCK) { return 1; --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153276; cv=none; d=zohomail.com; s=zohoarc; b=hZlHuwNHKWixq+OhelxmKZr+JLooaKwdW3G3yVTIp9VLp2/FJq6LksRd1ghj7/MchwS76YgzleL9rLYVbOU+jWSWYndOUXhfVH05Gm4gkPz2nivI5gld7j9l9NQRucWT1OfMnZYfeZ/8W//qVUYSHQb5O7ogJHX49kFyCiNN81I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153276; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=W5JLWmPdFOmmnVJajydlQuEvlPHJIdopD5Tg6fXJfks=; b=UM7lgM0vBGMWQ6ZCBgYwg2158VZ9Y1lpxpK10JzulFT1DwwyWUEIgyD3sllI5ndQhYpN/6XzeIvHklcpXs5EKx7Ge/So22FytKgxt12VoA1juTTwJw3a10CIh/UJA1MAYnASXANbNTi4lXT2YFf77dzY1O0PCaNBPKs/H7bcFkU= 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 1694153276534547.3778341339458; Thu, 7 Sep 2023 23:07:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUej-0000kJ-1e; Fri, 08 Sep 2023 02:07:49 -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 1qeUei-0000cF-2M for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:48 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUef-00081u-JZ for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:47 -0400 Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-565334377d0so1426091a12.2 for ; Thu, 07 Sep 2023 23:07:45 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.07.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:07:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153264; x=1694758064; 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=W5JLWmPdFOmmnVJajydlQuEvlPHJIdopD5Tg6fXJfks=; b=GE6Jd1GgGDOe+3d6YpA2aLT5vJ4lYdO7t6rCsO5OsnFyvkdC6T0MhewkimTlhVEQNj tNv0dZO7/Udrt3mPTRaK5X7quS4IwZpZSNHqk/uvkXSizYhdc/AHea6Kdvd61GQUWhPs Eq1z9bkAKfeXySHpnZ2qZMkN7tyGfoxzXUYRxdFjH4loxuVX6uGBAACk6SV0xVYxSX/M iA/Y5wMhN8QPRD7Cxn+9OwUrMorYc/9I7z4gGeb0PSwXbWMKpSjlt7/HKpOeEtj81bnZ 8G3ksyLT0WSLnMcs0OcfOyBB34q29j0M/e8rba9s8u5cUGt6DOuaSqg145T3vzaLAGbc vBMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153264; x=1694758064; 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=W5JLWmPdFOmmnVJajydlQuEvlPHJIdopD5Tg6fXJfks=; b=bz787jr2ZlOp310jgLFEosN93snjMu+BoX/84jjr4aUQQz0eQ2Ktf7a0+gb7RRh6nh ka9Pq8p+xecxUf+sknGI1npBWW+KmgPuJiOp0Ydh5kx0slDPv0izGnusllx2G3cpMjvY itAsxaTV5QqiAtayHcf+XA9t+ZtqXnXBDIa3GgqLE/I6cbn9Q4vX+N6T2/5tw7L2YTM9 U2qFdxza5lYihvPnDxml3it5Z+H/ncjdV0EBjIZuui2QHXPzY4dHApJrrVKpyN/5Wl4W sgIVhfJGHja3YsocyedwLhi0YfQ8vAVZRDFk7NQnZvxHIgFHSiz0TqSLIA6660WeC93+ l2Ng== X-Gm-Message-State: AOJu0Yy6SVQGUSwsZJITY2mfWRWrYbBq9YKfahofekJKUHgBiLp3wFkc 0qsZwY7M615pIZJopIRiSxjjS+J2H7Sf/vrb X-Google-Smtp-Source: AGHT+IGRijk7AxuqhJNptjrx84tSuCq7e4vJcX+YUpXeQNk66EqLJfsaZWa/DPY4ydZhI8N9l4V6Cw== X-Received: by 2002:a05:6a20:7d84:b0:132:ff57:7fab with SMTP id v4-20020a056a207d8400b00132ff577fabmr2404840pzj.2.1694153263827; Thu, 07 Sep 2023 23:07:43 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Tommy Wu , Frank Chang , Alistair Francis Subject: [PULL 44/65] target/riscv: Align the AIA model to v1.0 ratified spec Date: Fri, 8 Sep 2023 16:04:10 +1000 Message-ID: <20230908060431.1903919-45-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::52f; envelope-from=alistair23@gmail.com; helo=mail-pg1-x52f.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: 1694153277329100001 Content-Type: text/plain; charset="utf-8" From: Tommy Wu According to the new spec, when vsiselect has a reserved value, attempts from M-mode or HS-mode to access vsireg, or from VS-mode to access sireg, should preferably raise an illegal instruction exception. Signed-off-by: Tommy Wu Reviewed-by: Frank Chang Message-ID: <20230816061647.600672-1-tommy.wu@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/csr.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index b8e0d0cb4c..4a0f6a89be 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -1684,7 +1684,7 @@ static int rmw_iprio(target_ulong xlen, static int rmw_xireg(CPURISCVState *env, int csrno, target_ulong *val, target_ulong new_val, target_ulong wr_mask) { - bool virt; + bool virt, isel_reserved; uint8_t *iprio; int ret =3D -EINVAL; target_ulong priv, isel, vgein; @@ -1694,6 +1694,7 @@ static int rmw_xireg(CPURISCVState *env, int csrno, t= arget_ulong *val, =20 /* Decode register details from CSR number */ virt =3D false; + isel_reserved =3D false; switch (csrno) { case CSR_MIREG: iprio =3D env->miprio; @@ -1738,11 +1739,13 @@ static int rmw_xireg(CPURISCVState *env, int csrno,= target_ulong *val, riscv_cpu_mxl_bits(env)), val, new_val, wr_mask); } + } else { + isel_reserved =3D true; } =20 done: if (ret) { - return (env->virt_enabled && virt) ? + return (env->virt_enabled && virt && !isel_reserved) ? RISCV_EXCP_VIRT_INSTRUCTION_FAULT : RISCV_EXCP_ILLEGAL_INST; } return RISCV_EXCP_NONE; --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153399; cv=none; d=zohomail.com; s=zohoarc; b=CYa92Hs8SBchymoHoZdIeepelhFNURvXGRXISxFGnH916EeY/Lr8rP3jumLNzBYBdoxnkkefs7u6qBeBoUhq9FM/t1R+OM9bKfCqSRynHSxhJAoUQiRIoGTSBQER6q6TDOIwKNNn2PS6UuT/10q3B/DbTFXJ2yIyEoSIgQJNjkk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153399; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=V2SYdMaTh5B2DYvWJCJ2xIYyu0izkkUvTM4RwQhhWt8=; b=MTis1TYH08XFj0l7szpMwGyTDvHqN8RIvG2uHYbu0e48NkNPe0sNAtYF0iXQbFuYw94/SZHk5bbAlcn0aVCK+dgZBHWzQ8OC4Tw2qhMwHrlpkK6ZNoLUCExoGiVdKXtTY8ZFeoKFItAYePSWTmzy+l4/8K6KROy1tk9+8Jz2q6U= 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 16941533999091018.5315789759957; Thu, 7 Sep 2023 23:09:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUem-00016c-6b; Fri, 08 Sep 2023 02:07:52 -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 1qeUel-00010s-3r for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:51 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUei-00086L-N3 for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:50 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1c1f8aaab9aso14776545ad.1 for ; Thu, 07 Sep 2023 23:07:48 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.07.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:07:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153267; x=1694758067; 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=V2SYdMaTh5B2DYvWJCJ2xIYyu0izkkUvTM4RwQhhWt8=; b=sG0oBPKpeVV1CEdoq1RAQIs8XU+VqRfYzkY2q8Wv+c6oUerMzxGVlXwmb7xYowczl0 vP39mZswKcGNPbg6bTVJqwO1/UiGBUEMBvtrXYB4kaOQ0TPIVtsTiLBQwSWzH5yWqIyk +WPv6qASme3frh0KxnRzyxOPIVZK65tk0Wj8kcCZWiu4G/1ajVasItlhKAB9hl76pLmR a9pDHT3lgjzTKAR7GD6yMmfbcB6EJnLYuRqaeCVeoIIaCkKsQJ97AaFtbJNBP9cBg1qJ iIvxezniWvXQaMRSCP/huscgUsHaV/6GhTvBql2gAk2vleMHVe1t7Yo5Xr9r50VVBtVW 8DTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153267; x=1694758067; 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=V2SYdMaTh5B2DYvWJCJ2xIYyu0izkkUvTM4RwQhhWt8=; b=oNljDjuwJqjCQ6cvAeeVYLKspuLLgyMgzPjAjdrKIhlz4f8quOEOI83zX/qegFIKLR 6UQVFhAWXwbewaMihYZ3QIzkVgWYmepKXAWC2tXdHjh4dZciI9OWy/g8RaKJj0oXOHxf m7CTqog9X2uWHR2I+/v+UkKyoXsx3kBl5uLa7Ig16w7iJ9512GXPwGUsY6o7153H6yGS viSd6weQ/o/xqle3ppzSX1getEtgy68D63VoLhrOO7yVresxEwdd1psTiMbKzN96ix3Y zyU7m9QDPt8iLu9kY1kmHKuvoUjfvaNXydAeptnfzGwMlhaI3danVLtgowCHbycIwEyA oTyA== X-Gm-Message-State: AOJu0YzQkgh1WpNVo/rutEOmunIeqPVPmrZJGfoUCt2W7V+UR8Be/j/v p37k/pitpY9c8AKMGYO/vm4ojrWtbWOOa4Z8 X-Google-Smtp-Source: AGHT+IHj7l+i0mTgZINozOhRCYzryZLYvauDY5sDdVdEKCVKxVxZkmcuha/yRo0RJFqd3103AYlQ0Q== X-Received: by 2002:a17:902:f546:b0:1bb:7f71:df43 with SMTP id h6-20020a170902f54600b001bb7f71df43mr1796073plf.34.1694153267010; Thu, 07 Sep 2023 23:07:47 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Nikita Shubin , Alistair Francis Subject: [PULL 45/65] target/riscv: don't read CSR in riscv_csrrw_do64 Date: Fri, 8 Sep 2023 16:04:11 +1000 Message-ID: <20230908060431.1903919-46-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::62b; envelope-from=alistair23@gmail.com; helo=mail-pl1-x62b.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: 1694153401073100009 Content-Type: text/plain; charset="utf-8" From: Nikita Shubin As per ISA: "For CSRRWI, if rd=3Dx0, then the instruction shall not read the CSR and shall not cause any of the side effects that might occur on a CSR read." trans_csrrwi() and trans_csrrw() call do_csrw() if rd=3Dx0, do_csrw() calls riscv_csrrw_do64(), via helper_csrw() passing NULL as *ret_value. Signed-off-by: Nikita Shubin Reviewed-by: Alistair Francis Message-ID: <20230808090914.17634-1-nikita.shubin@maquefel.me> Signed-off-by: Alistair Francis --- target/riscv/csr.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 4a0f6a89be..e51815c448 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -3917,21 +3917,27 @@ static RISCVException riscv_csrrw_do64(CPURISCVStat= e *env, int csrno, target_ulong write_mask) { RISCVException ret; - target_ulong old_value; + target_ulong old_value =3D 0; =20 /* execute combined read/write operation if it exists */ if (csr_ops[csrno].op) { return csr_ops[csrno].op(env, csrno, ret_value, new_value, write_m= ask); } =20 - /* if no accessor exists then return failure */ - if (!csr_ops[csrno].read) { - return RISCV_EXCP_ILLEGAL_INST; - } - /* read old value */ - ret =3D csr_ops[csrno].read(env, csrno, &old_value); - if (ret !=3D RISCV_EXCP_NONE) { - return ret; + /* + * ret_value =3D=3D NULL means that rd=3Dx0 and we're coming from help= er_csrw() + * and we can't throw side effects caused by CSR reads. + */ + if (ret_value) { + /* if no accessor exists then return failure */ + if (!csr_ops[csrno].read) { + return RISCV_EXCP_ILLEGAL_INST; + } + /* read old value */ + ret =3D csr_ops[csrno].read(env, csrno, &old_value); + if (ret !=3D RISCV_EXCP_NONE) { + return ret; + } } =20 /* write value if writable and write mask set, otherwise drop writes */ --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153494; cv=none; d=zohomail.com; s=zohoarc; b=LUc99RZZfYURkl1WB8NMdmSzbrCNAFFi5AyMm+V57K5k24rCxHu7qTvJ+QSOAY5Uo+6nbxGiLdUm0jHxoqM01q2Zm/8QqXLDccn11vE7ay9kg6chgo8U0ZeHcDQTlyNHnTxsoAqdct+ZOW08xlmWfnvlcMfbtjOHoV0PZBdw9sg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153494; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bABsxxQ7+tNcrX3qthQfqpT8IQqITVxbBzeGNSCTapU=; b=Az8l64+G1q36vSy26qQVxSbvbAv9BRAXI9RhWBvBx8gwIpAsv6yYKBo7D3NDWFMWLeEGNU5d4rBuPJFVYe1BLrCKR19ZanV4XaSCRevPD4Wn9MA2kWUi+7f2pbjUkmv3HI6A6QxJVSBXNNxpOs9z7hUY9OUiZFQin06mTYe3HsA= 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 1694153494794161.3370431075715; Thu, 7 Sep 2023 23:11:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUer-0001OJ-8K; Fri, 08 Sep 2023 02:07:57 -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 1qeUep-0001Fm-6H for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:55 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUem-00087Z-MX for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:54 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1c1ff5b741cso15462145ad.2 for ; Thu, 07 Sep 2023 23:07:52 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.07.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:07:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153271; x=1694758071; 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=bABsxxQ7+tNcrX3qthQfqpT8IQqITVxbBzeGNSCTapU=; b=axjimo7DPY/qnFlsOrGtn6KA+Ai40PVnoWswh1dc+eLPmtjlT08ohj/I8pVyRsGfEk 1Pox3gmztosE4WtVRpADTEpNN1ZExYTRwi0uYYxOZxggbY+PtJD+PHmX8atEJLGpWdfS Sn9B7DL/RiiMGou3zoZvKJ9r36/h2GnaRC8PNqNREQhneoxVQWtgV//eOUWEB6bwATmZ n9FGyG1HwoKCU4Glf4aDioduBcr2dpxcNDdX+UVVXHy/pUKJqD3nFZv+knvZ6WpT4gwA N4CA459wG/YTm6x/AnrbPONipqH3+qgS5kVXLurLTFKTvNHyFsrhvpvM2GJWC7JGd5EI /iVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153271; x=1694758071; 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=bABsxxQ7+tNcrX3qthQfqpT8IQqITVxbBzeGNSCTapU=; b=lcQJfBFSo+7w8GuyKmWMMwHV24+LooTR+hhOHWAtxpbqiSFHRG0n1KYfWCQYjWCibB KmA+jJYL7KXGg2lVlNuR3jciNWw0qSUHZLByp+o1ETAVuP5I3YqkKX4QcE++kmxhNmTV MAlDQdCn1orMWKRaPXLKLFXJOfoAQp4wxrTW/oVwuAREVApzZAJOYix0bXGryfai/tyu dWDTydoodXuVuQxGxNE5tz7zh4FxseeU9+6zuRsZKD2RKtauWd4w/OsK2BtBZNXBfAFN BdKnx0t4f/MuK4RpMXPaGwXvWtC4Vlozf5iDlbhKwJf7gmu2dLffeMVzpshziA5PpvrZ 2sWw== X-Gm-Message-State: AOJu0Yxk2xY03zSBpaDwiGPjfqRCTo0UGbiKi2ozKrXQqtZS6RPwJ91n DBymlX+GogPbDT2wXkqZ7dCTJv7/VijIIVQZ X-Google-Smtp-Source: AGHT+IGgCtGDccdTwMGxaluUHqwdIuq/t9bXaJsTVqcPB2qKa2gM+L7OlyTg4i2xfkMvcN4LuFUcIQ== X-Received: by 2002:a17:902:e74b:b0:1b9:ea60:cd82 with SMTP id p11-20020a170902e74b00b001b9ea60cd82mr1782952plf.5.1694153270954; Thu, 07 Sep 2023 23:07:50 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Weiwei Li , Alistair Francis , Andrew Jones Subject: [PULL 46/65] target/riscv/cpu.c: split CPU options from riscv_cpu_extensions[] Date: Fri, 8 Sep 2023 16:04:12 +1000 Message-ID: <20230908060431.1903919-47-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::636; envelope-from=alistair23@gmail.com; helo=mail-pl1-x636.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: 1694153495400100005 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza We'll add a new CPU type that will enable a considerable amount of extensions. To make it easier for us we'll do a few cleanups in our existing riscv_cpu_extensions[] array. Start by splitting all CPU non-boolean options from it. Create a new riscv_cpu_options[] array for them. Add all these properties in riscv_cpu_add_user_properties() as it is already being done today. 'mmu' and 'pmp' aren't really extensions in the usual way we think about RISC-V extensions. These are closer to CPU features/options, so move both to riscv_cpu_options[] too. In the near future we'll need to match all extensions with all entries in isa_edata_arr[], and so it happens that both 'mmu' and 'pmp' do not have a riscv,isa string (thus, no priv spec version restriction). This further emphasizes the point that these are more a CPU option than an extension. No functional changes made. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones Message-ID: <20230901194627.1214811-2-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index f227c7664e..fdbd8eb0b8 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1810,7 +1810,6 @@ static void riscv_cpu_add_misa_properties(Object *cpu= _obj) =20 static Property riscv_cpu_extensions[] =3D { /* Defaults for standard extensions */ - DEFINE_PROP_UINT8("pmu-num", RISCVCPU, cfg.pmu_num, 16), DEFINE_PROP_BOOL("sscofpmf", RISCVCPU, cfg.ext_sscofpmf, false), DEFINE_PROP_BOOL("Zifencei", RISCVCPU, cfg.ext_ifencei, true), DEFINE_PROP_BOOL("Zicsr", RISCVCPU, cfg.ext_icsr, true), @@ -1823,15 +1822,8 @@ static Property riscv_cpu_extensions[] =3D { DEFINE_PROP_BOOL("Zve32f", RISCVCPU, cfg.ext_zve32f, false), DEFINE_PROP_BOOL("Zve64f", RISCVCPU, cfg.ext_zve64f, false), DEFINE_PROP_BOOL("Zve64d", RISCVCPU, cfg.ext_zve64d, false), - DEFINE_PROP_BOOL("mmu", RISCVCPU, cfg.mmu, true), - DEFINE_PROP_BOOL("pmp", RISCVCPU, cfg.pmp, true), DEFINE_PROP_BOOL("sstc", RISCVCPU, cfg.ext_sstc, true), =20 - DEFINE_PROP_STRING("priv_spec", RISCVCPU, cfg.priv_spec), - DEFINE_PROP_STRING("vext_spec", RISCVCPU, cfg.vext_spec), - DEFINE_PROP_UINT16("vlen", RISCVCPU, cfg.vlen, 128), - DEFINE_PROP_UINT16("elen", RISCVCPU, cfg.elen, 64), - DEFINE_PROP_BOOL("smstateen", RISCVCPU, cfg.ext_smstateen, false), DEFINE_PROP_BOOL("svadu", RISCVCPU, cfg.ext_svadu, true), DEFINE_PROP_BOOL("svinval", RISCVCPU, cfg.ext_svinval, false), @@ -1862,9 +1854,7 @@ static Property riscv_cpu_extensions[] =3D { DEFINE_PROP_BOOL("zhinxmin", RISCVCPU, cfg.ext_zhinxmin, false), =20 DEFINE_PROP_BOOL("zicbom", RISCVCPU, cfg.ext_icbom, true), - DEFINE_PROP_UINT16("cbom_blocksize", RISCVCPU, cfg.cbom_blocksize, 64), DEFINE_PROP_BOOL("zicboz", RISCVCPU, cfg.ext_icboz, true), - DEFINE_PROP_UINT16("cboz_blocksize", RISCVCPU, cfg.cboz_blocksize, 64), =20 DEFINE_PROP_BOOL("zmmul", RISCVCPU, cfg.ext_zmmul, false), =20 @@ -1918,6 +1908,21 @@ static Property riscv_cpu_extensions[] =3D { DEFINE_PROP_END_OF_LIST(), }; =20 +static Property riscv_cpu_options[] =3D { + DEFINE_PROP_UINT8("pmu-num", RISCVCPU, cfg.pmu_num, 16), + + DEFINE_PROP_BOOL("mmu", RISCVCPU, cfg.mmu, true), + DEFINE_PROP_BOOL("pmp", RISCVCPU, cfg.pmp, true), + + DEFINE_PROP_STRING("priv_spec", RISCVCPU, cfg.priv_spec), + DEFINE_PROP_STRING("vext_spec", RISCVCPU, cfg.vext_spec), + + DEFINE_PROP_UINT16("vlen", RISCVCPU, cfg.vlen, 128), + DEFINE_PROP_UINT16("elen", RISCVCPU, cfg.elen, 64), + + DEFINE_PROP_UINT16("cbom_blocksize", RISCVCPU, cfg.cbom_blocksize, 64), + DEFINE_PROP_UINT16("cboz_blocksize", RISCVCPU, cfg.cboz_blocksize, 64), +}; =20 #ifndef CONFIG_USER_ONLY static void cpu_set_cfg_unavailable(Object *obj, Visitor *v, @@ -1986,6 +1991,14 @@ static void riscv_cpu_add_user_properties(Object *ob= j) #endif qdev_property_add_static(dev, prop); } + + for (int i =3D 0; i < ARRAY_SIZE(riscv_cpu_options); i++) { + /* Check if KVM created the property already */ + if (object_property_find(obj, riscv_cpu_options[i].name)) { + continue; + } + qdev_property_add_static(dev, &riscv_cpu_options[i]); + } } =20 static Property riscv_cpu_properties[] =3D { --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153667; cv=none; d=zohomail.com; s=zohoarc; b=el3UDws2rihVxze+qUCwWVZh3JGjAEWhhFSRE+WwsUhg6bc6kfMZS3MtBzKEJCysaA6c8e6Dfs4+2S0oqSb/pNfYYAdryopBHcvLd1yHwtQjeD/20jnHq4HW/oeDFOnZgNdMyIyhVH8iiYLRFNzyvtt7XMkcl+mDVk86JD6WURE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153667; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IUuPwbzWdYwAH4mFJmcOk/0YkSmA5lbZ2mPYnykgtP0=; b=dvJm6VKZegFxFujaopRcToLXAkJzt8e0VkUd0yZyFfzh3vvPnuUCKcV2Y5F8cbBKfGz98J4d0jOdC/tDkRi2KxIt83UiOMB7gxWgDnVwTl+aRHjt/qMiOfoaSUoZBYRr3y9O8VJ4DzhzrR4FRME8Ruqhzw4IfiV3EtmGlUTvReY= 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 1694153666882247.08995008507156; Thu, 7 Sep 2023 23:14:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUev-0001ek-Ct; Fri, 08 Sep 2023 02:08:01 -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 1qeUes-0001SI-Dj for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:58 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUeq-00087t-4T for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:07:58 -0400 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1c3887039d4so556965ad.1 for ; Thu, 07 Sep 2023 23:07:55 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.07.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:07:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153274; x=1694758074; 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=IUuPwbzWdYwAH4mFJmcOk/0YkSmA5lbZ2mPYnykgtP0=; b=Dy3K1NRyO/dFulMQ91IGrrnEjJidGFVyWW/22aEuGh/9dlAA1LGvrJM4eHrE2K0Foh bnHNcDoBTSVl9SfpHlpM14cvicxvEwGTjerlR2zY0XroGr4vZK6iuCOl51uZ3zVFokRw NF8wSTf656kxgnHaGQNdqO7y6+LBwPaWr+LROcYbKCSZGbZ9D8Nczs5UkdkpWnYror3d V9qg/hbYD4AmQ5ivPVeEaMQh8Pm/Mx3aeGpyuxoO3HxwL7Altfmq7HuB8DSyp8alfm2I kDayhOSz6qMGZ27LADdgXPiS1uskVoTEX6zZeU62oJpf3ajtuEt7Xz+QDKSk63J8AC8t LhNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153274; x=1694758074; 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=IUuPwbzWdYwAH4mFJmcOk/0YkSmA5lbZ2mPYnykgtP0=; b=nTJBFVZ1HBigqdmesWk08FqzX7ZFm4QekQorKQn2UqN06gJB1C07uZM8wkF+8duc5H NO8HAv865cPj9nvx/QMN68uOhEv3FUAUqo79RX6cmOrrlYs5dra25mdbSc+0LiXVDwHg 5u1zr0LT9gos15qeYdVDSZwIymJ+YsmJ2YiDTHPfUzzX1WSocegJU62UGDV+FayLtlyG B5at6oWgrz4RIHxHHHCxORf1CveTDH0xTCeq0p4GQQPx/BU5AOeZME59PyCCwDB1UHdh VxROnHqtZIczHPo2+dyHvlkwceR8e1OQqMHlAoJrx0u7ckFuVNyOjOC6oZwwjteoVuwm rQxg== X-Gm-Message-State: AOJu0YxFJD+ODxp1mwBphSX7cPunHLRputlfxweRaqUCNR6K2YxgmU4D GUI+Vtem/0W3tk07M6DrqN/IndIdz1zICqtN X-Google-Smtp-Source: AGHT+IEtcZsFZjSMiKSFCvfr41OBDhA+94T5rQtRyTQeTq4swXfyxaHvwNmq1pO2CPSjNCJ+KoYJQg== X-Received: by 2002:a17:902:7483:b0:1bb:891b:8bd with SMTP id h3-20020a170902748300b001bb891b08bdmr1845363pll.34.1694153274336; Thu, 07 Sep 2023 23:07:54 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Alistair Francis , Andrew Jones Subject: [PULL 47/65] target/riscv/cpu.c: skip 'bool' check when filtering KVM props Date: Fri, 8 Sep 2023 16:04:13 +1000 Message-ID: <20230908060431.1903919-48-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::630; envelope-from=alistair23@gmail.com; helo=mail-pl1-x630.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: 1694153668405100001 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza After the introduction of riscv_cpu_options[] all properties in riscv_cpu_extensions[] are booleans. This check is now obsolete. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones Message-ID: <20230901194627.1214811-3-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index fdbd8eb0b8..db640e7460 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1976,17 +1976,11 @@ static void riscv_cpu_add_user_properties(Object *o= bj) * Set the default to disabled for every extension * unknown to KVM and error out if the user attempts * to enable any of them. - * - * We're giving a pass for non-bool properties since they're - * not related to the availability of extensions and can be - * safely ignored as is. */ - if (prop->info =3D=3D &qdev_prop_bool) { - object_property_add(obj, prop->name, "bool", - NULL, cpu_set_cfg_unavailable, - NULL, (void *)prop->name); - continue; - } + object_property_add(obj, prop->name, "bool", + NULL, cpu_set_cfg_unavailable, + NULL, (void *)prop->name); + continue; } #endif qdev_property_add_static(dev, prop); --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153482; cv=none; d=zohomail.com; s=zohoarc; b=GZq9yOHot8R+fG5K0O77DN791yF4hfTHXDWDvD6CzOtaoj8iA9wxjh6ecTZ6BNjtT84wK6Fz5T4GWJb1gtuuuVzcqemMpChc98/leeRXGNDw1LumOM4gIq7R6W4nNHrmfTH8E+9aG73DZ2TKdAWX7OTyUfWp84mhiFrnLVFJcn0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153482; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IUXcB6XVSWmo55bkJAg6B9TNKFC1NEbNu669DNeqcsE=; b=fouSW4e21eHMCS3Sb1Bc861y8mB4D4IlJVaQJGdS2rGkmQVz4wD9Tk0Nnk+VeB7vn5OSkTfafCyPZYlY7Lqzv/Z2R+R0wf/QSrIuLnahKW2gHudyaS4s80JVgOwyWUw67VV9C/g0hzBSbT9loK3KupfzRFR+x5tTowHG5GdXlME= 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 169415348234596.48836262439238; Thu, 7 Sep 2023 23:11:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUf1-0001wa-IY; Fri, 08 Sep 2023 02:08:07 -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 1qeUf0-0001uu-Af for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:06 -0400 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 1qeUet-00088C-Tb for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:06 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1c34c9cc9b9so13563565ad.3 for ; Thu, 07 Sep 2023 23:07:59 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.07.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:07:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153278; x=1694758078; 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=IUXcB6XVSWmo55bkJAg6B9TNKFC1NEbNu669DNeqcsE=; b=ZpO0it1U00dTSnVoOZR2ADSMNnQkpRjaD0HfvB/GLNSTSs1NK+Lq2GL0sDGnu3iozx QRKZG8GDy47mnYbDloHw3/2W2ODOZU+iKEbPIg8lpoh1Bj3U+ZE3x8l/WKpVof2hefW/ 0CuISuH8L8TlOG8jLT2ZhqXfQPV4Xkmn9sNtB0fQGQRUPYR6uqy87RDd81U5hzRz8/Q4 5f1zXQKfnV6ccHQFUFqddBGqPzYSLwz73KtyZMY8pcJ1DTiwJczm3XbIyPJaWopBj1nW h14WTfgw2cyBEeLWzYq/YA1p/B52Wmq0E8eIhHZRb4KZO2p8RWL+OJMwe2UCUlJ3A6ej wjqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153278; x=1694758078; 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=IUXcB6XVSWmo55bkJAg6B9TNKFC1NEbNu669DNeqcsE=; b=JHIqctpYR7gvvAYkZBC2fw0WCLRQJvCPoPKXzUz4cWC4z2tnM2csoPpZSHkRIqUJ4c t7I9XEAlmaDSJZLLqXGNRG22w3X2DpHTZz35aW2JkEpgmN9FtIx3qzx6Qt+tPtMFzVFB JjRCNZpWxH4Dg1L4SwXHjMntQxpu8JUnurrBi9aGJZDbUyFgssHypyS5VJMPRF8ioI4N U96caYiDnTzR9h0HqbA+L97SRDA04hjFxrbulAQk9qWJdWXIitQx0ngxQM0GaOEtCgij rFlsOPUM+BlXksa28kof6wsFbh2nTU0zdWfijDV2kUgfZkHqqS+Mw8aNbd6lYbjJSLP0 N7tw== X-Gm-Message-State: AOJu0YxL5+MkB53eDO2gts/Gv6io4G3msZ0OeOQkzKx2l2JOVra+lRZc R1ZjFiTTOnLw9QfVekAs+BuC06RqHnjcKCJ/ X-Google-Smtp-Source: AGHT+IGyOudccjU3gO1Dstwaz4eyhYHlkIVPTbk0xpNm33deDsEqjJuINLehFonlAnE5qaI0zGwf0Q== X-Received: by 2002:a17:902:c40a:b0:1c3:21ae:7a4a with SMTP id k10-20020a170902c40a00b001c321ae7a4amr2279615plk.38.1694153278221; Thu, 07 Sep 2023 23:07:58 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Weiwei Li , Alistair Francis , Andrew Jones Subject: [PULL 48/65] target/riscv/cpu.c: split kvm prop handling to its own helper Date: Fri, 8 Sep 2023 16:04:14 +1000 Message-ID: <20230908060431.1903919-49-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::631; envelope-from=alistair23@gmail.com; helo=mail-pl1-x631.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: 1694153483110100003 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza Future patches will split the existing Property arrays even further, and the existing code in riscv_cpu_add_user_properties() will start to scale bad with it because it's dealing with KVM constraints mixed in with TCG constraints. We're going to pay a high price to share a couple of common lines of code between the two. Create a new riscv_cpu_add_kvm_properties() that will be forked from riscv_cpu_add_user_properties() if we're running KVM. The helper includes all properties that a KVM CPU will add. The rest of riscv_cpu_add_user_properties() body will then be relieved from having to deal with KVM constraints. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones Message-ID: <20230901194627.1214811-4-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 65 ++++++++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 23 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index db640e7460..8e6d316500 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1943,6 +1943,46 @@ static void cpu_set_cfg_unavailable(Object *obj, Vis= itor *v, } #endif =20 +#ifndef CONFIG_USER_ONLY +static void riscv_cpu_add_kvm_unavail_prop(Object *obj, const char *prop_n= ame) +{ + /* Check if KVM created the property already */ + if (object_property_find(obj, prop_name)) { + return; + } + + /* + * Set the default to disabled for every extension + * unknown to KVM and error out if the user attempts + * to enable any of them. + */ + object_property_add(obj, prop_name, "bool", + NULL, cpu_set_cfg_unavailable, + NULL, (void *)prop_name); +} + +static void riscv_cpu_add_kvm_properties(Object *obj) +{ + Property *prop; + DeviceState *dev =3D DEVICE(obj); + + kvm_riscv_init_user_properties(obj); + riscv_cpu_add_misa_properties(obj); + + for (prop =3D riscv_cpu_extensions; prop && prop->name; prop++) { + riscv_cpu_add_kvm_unavail_prop(obj, prop->name); + } + + for (int i =3D 0; i < ARRAY_SIZE(riscv_cpu_options); i++) { + /* Check if KVM created the property already */ + if (object_property_find(obj, riscv_cpu_options[i].name)) { + continue; + } + qdev_property_add_static(dev, &riscv_cpu_options[i]); + } +} +#endif + /* * Add CPU properties with user-facing flags. * @@ -1958,39 +1998,18 @@ static void riscv_cpu_add_user_properties(Object *o= bj) riscv_add_satp_mode_properties(obj); =20 if (kvm_enabled()) { - kvm_riscv_init_user_properties(obj); + riscv_cpu_add_kvm_properties(obj); + return; } #endif =20 riscv_cpu_add_misa_properties(obj); =20 for (prop =3D riscv_cpu_extensions; prop && prop->name; prop++) { -#ifndef CONFIG_USER_ONLY - if (kvm_enabled()) { - /* Check if KVM created the property already */ - if (object_property_find(obj, prop->name)) { - continue; - } - - /* - * Set the default to disabled for every extension - * unknown to KVM and error out if the user attempts - * to enable any of them. - */ - object_property_add(obj, prop->name, "bool", - NULL, cpu_set_cfg_unavailable, - NULL, (void *)prop->name); - continue; - } -#endif qdev_property_add_static(dev, prop); } =20 for (int i =3D 0; i < ARRAY_SIZE(riscv_cpu_options); i++) { - /* Check if KVM created the property already */ - if (object_property_find(obj, riscv_cpu_options[i].name)) { - continue; - } qdev_property_add_static(dev, &riscv_cpu_options[i]); } } --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153401; cv=none; d=zohomail.com; s=zohoarc; b=TNQqtaHZWDt5F20uzLzyDk+zFo730dNDTY+K0Nx1wSVetVV8gQTUh9b/nsCBEy3Hb67VSzACFWEdRcKA9YDPqLbAY6Drc1A74qu/5YO1KIOD/X/jK66A+SPU8r8eYqCIiYEr8cazKm/+jRUnXvMeolhOwZBKHd6k2wTL93rD0ao= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153401; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LPBDnNliWcR4/YKIzdIN9ar2Uubwbp/TYyz5T00Sd2A=; b=jcbUY3hXhE8nVhePVr7Spt67Sdl/6JOrY2/d18MLz8bkK0wAfjN2AGn97cj2FQHIiRtcVSZ/Dj9ofb2E7isMUbJDHxxz8jUWMSOOaEZjYgGVDUqh1JC3oIlS6mdCZAOrU/cami7wrJUH4RTcSmW/GKqpffbT9kvoQs/C16rePpg= 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 1694153401005238.88809388680227; Thu, 7 Sep 2023 23:10:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUf2-0001yu-R2; Fri, 08 Sep 2023 02:08:08 -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 1qeUf1-0001w9-45 for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:07 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUey-00088a-Nc for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:06 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1c06f6f98c0so13951065ad.3 for ; Thu, 07 Sep 2023 23:08:03 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.07.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:08:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153282; x=1694758082; 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=LPBDnNliWcR4/YKIzdIN9ar2Uubwbp/TYyz5T00Sd2A=; b=OXnwgD8cHDP7uvocyYla1PFD5Ejnw0q3WIvFBW2JEeCWFuRZRFYTueImYB6gsnyQVX xHeCO06kgMtff78pYhWxOfhgnaE+EdPJq49xXlH9WHtddvF7tt8SeYsraZFMx+tCqRwl R7HqmC854tj/j47HBc6uShwGgZfmEIQa1pdMFFgwUfhTAHjKwTWReEtUmD0XWrD94r8a mOpw5OpZ5YwjP1EjtPLXOC49RdtsF2mz9Ck/elWU/S5ulON+PtM2WnjeC+5il9vk66sP kRxN3v/0KNxYifB5fGgVwGHRPks2AS8iqImxwc/2qtVIwQIZMtT74c+wKI6jcres/Un8 y7ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153282; x=1694758082; 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=LPBDnNliWcR4/YKIzdIN9ar2Uubwbp/TYyz5T00Sd2A=; b=LgOLxTnfcjFo4XIIcbgiS/U8PgmTEhrQN3hMKH2QEz5JoBsKT96zBYrqVzdkFu3UHd NcAUP4hh+akA1F110HNWNcGsc6j/OAWf2vAlT9yV7JORJZDEWZDQIo6oeLN3qtPx8Ugp mgoBaY3djFJhv/DHs3gHYZGy5Ul5T4Hoy0bXNGVyYQDFbcxCi0l/mfQHR2WhqEV5aSd8 eUYDoy2ioB2M7LdyE4qemnNjRe2R3JubTEUQ5/x9/3v/hyQ3K6k4Zzo/jMkHZ+qut4Rc zN9kcBB9owHPOVdw7PinK2s6NgSkd2O6VeM/9dCw3oPEH6Ldh5CWjMCzjXZKdHqUEhpu VnMg== X-Gm-Message-State: AOJu0Yw3DLcd35jdRpgibrnoOUzqzeu54Jn9xyyISu/hCjfaOccqI9Eq EM69P4Mf5SpDIO7PYl9eahX//BmsC95rEJNS X-Google-Smtp-Source: AGHT+IFeojGqtnHqUlvvj+wAdJE2zl97nFGRpFv9tasW2UUDjBnWvMrWiCatdHx5L92jfKT5qt5JgA== X-Received: by 2002:a17:903:2303:b0:1bd:e998:ec0a with SMTP id d3-20020a170903230300b001bde998ec0amr1834730plh.67.1694153281945; Thu, 07 Sep 2023 23:08:01 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Andrew Jones , Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 49/65] target/riscv: add DEFINE_PROP_END_OF_LIST() to riscv_cpu_options[] Date: Fri, 8 Sep 2023 16:04:15 +1000 Message-ID: <20230908060431.1903919-50-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::635; envelope-from=alistair23@gmail.com; helo=mail-pl1-x635.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: 1694153402969100013 From: Daniel Henrique Barboza Add DEFINE_PROP_END_OF_LIST() and eliminate the ARRAY_SIZE() usage when iterating in the riscv_cpu_options[] array, making it similar to what we already do when working with riscv_cpu_extensions[]. We also have a more sophisticated motivation behind this change. In the future we might need to export riscv_cpu_options[] to other files, and ARRAY_LIST() doesn't work properly in that case because the array size isn't exposed to the header file. Here's a future sight of what we would deal with: ./target/riscv/kvm.c:1057:5: error: nested extern declaration of 'riscv_cpu= _add_misa_properties' [-Werror=3Dnested-externs] n file included from ../target/riscv/kvm.c:19: home/danielhb/work/qemu/include/qemu/osdep.h:473:31: error: invalid applica= tion of 'sizeof' to incomplete type 'const RISCVCPUMultiExtConfig[]' 473 | #define ARRAY_SIZE(x) ((sizeof(x) / sizeof((x)[0])) + \ | ^ ./target/riscv/kvm.c:1047:29: note: in expansion of macro 'ARRAY_SIZE' 1047 | for (int i =3D 0; i < ARRAY_SIZE(_array); i++) { \ | ^~~~~~~~~~ ./target/riscv/kvm.c:1059:5: note: in expansion of macro 'ADD_UNAVAIL_KVM_P= ROP_ARRAY' 1059 | ADD_UNAVAIL_KVM_PROP_ARRAY(obj, riscv_cpu_extensions); | ^~~~~~~~~~~~~~~~~~~~~~~~~~ home/danielhb/work/qemu/include/qemu/osdep.h:473:31: error: invalid applica= tion of 'sizeof' to incomplete type 'const RISCVCPUMultiExtConfig[]' 473 | #define ARRAY_SIZE(x) ((sizeof(x) / sizeof((x)[0])) + \ | ^ ./target/riscv/kvm.c:1047:29: note: in expansion of macro 'ARRAY_SIZE' 1047 | for (int i =3D 0; i < ARRAY_SIZE(_array); i++) { \ Homogenize the present and change the future by using DEFINE_PROP_END_OF_LIST() in riscv_cpu_options[]. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-ID: <20230901194627.1214811-5-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 8e6d316500..8662414906 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1922,6 +1922,8 @@ static Property riscv_cpu_options[] =3D { =20 DEFINE_PROP_UINT16("cbom_blocksize", RISCVCPU, cfg.cbom_blocksize, 64), DEFINE_PROP_UINT16("cboz_blocksize", RISCVCPU, cfg.cboz_blocksize, 64), + + DEFINE_PROP_END_OF_LIST(), }; =20 #ifndef CONFIG_USER_ONLY @@ -1973,12 +1975,12 @@ static void riscv_cpu_add_kvm_properties(Object *ob= j) riscv_cpu_add_kvm_unavail_prop(obj, prop->name); } =20 - for (int i =3D 0; i < ARRAY_SIZE(riscv_cpu_options); i++) { + for (prop =3D riscv_cpu_options; prop && prop->name; prop++) { /* Check if KVM created the property already */ - if (object_property_find(obj, riscv_cpu_options[i].name)) { + if (object_property_find(obj, prop->name)) { continue; } - qdev_property_add_static(dev, &riscv_cpu_options[i]); + qdev_property_add_static(dev, prop); } } #endif @@ -2009,8 +2011,8 @@ static void riscv_cpu_add_user_properties(Object *obj) qdev_property_add_static(dev, prop); } =20 - for (int i =3D 0; i < ARRAY_SIZE(riscv_cpu_options); i++) { - qdev_property_add_static(dev, &riscv_cpu_options[i]); + for (prop =3D riscv_cpu_options; prop && prop->name; prop++) { + qdev_property_add_static(dev, prop); } } =20 --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153305; cv=none; d=zohomail.com; s=zohoarc; b=JS/q7LT5lkBhZCmFRfB/gFMc8kd9RRLosyFeV4x9HHqm6dMqHKVjCIVLz6Yv/rngnK2G0KdbXSwsC3SrSFeVCyGKoXqkPaozOsS9onwq6p0Hee13v1K5JdbicaKTqlrO6Wrsqkg5llxiERsm/js7VzSAmmws92DU5+KSR9i1wRE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153305; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Mw+mzSdrCh9Y5DGC49hd2vxht5biTpPIyW2r+s5t1ok=; b=LQ8nhIlH29lFGTQl6EqkcKspmVjotcT4hgf64e0PsVVMgnxOejxRGY0PytaKSng1UxXFJ6OU+6YnZQ42Zgr5zOxUFKQB3ce8B+08mW3EbYD0o6B2oOQ8NuTGWgDxsc6fwLwDbm/0Ss9FcNFa7MMZRXuSMZwEteAkV2jboOpkWbE= 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 1694153305136341.1921172588966; Thu, 7 Sep 2023 23:08:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUf6-0002KV-EU; Fri, 08 Sep 2023 02:08:12 -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 1qeUf4-00023s-Oj for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:10 -0400 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 1qeUf1-000893-C3 for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:09 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1c34c9cc9b9so13564165ad.3 for ; Thu, 07 Sep 2023 23:08:06 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.08.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:08:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153285; x=1694758085; 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=Mw+mzSdrCh9Y5DGC49hd2vxht5biTpPIyW2r+s5t1ok=; b=bLZpJyzQtu9+TepE9QPnsDfMG0iMJd//BySVwtkkwL2fiHMbu+YdShfCQ+vXS3QiQ0 e7vTUKfvkBB3PH35v9CnTiROx5LMfJDmef2HDgLiqIcWhqSYDoLWR2caA33bRQxLq0Gi LPiYo+ZCdr0Db7Zl9HGvLKOrmldY6YO9sOSGK0jPardeq/5vdKHIWKhzZOd76zGsqJS+ WdsjgZ+qPTgw0LA/w8b3puKdzhPI7fsI8Hy1seKtKlZSV5wGQB4EdF1uR0Gaik/pG2wN ixilXaxbbDbbJo7f/elEjZRjYVwDDZs3xCA0FkiQsC3qyoqTqKnBGLKs0T7dXzJS/slX IFkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153285; x=1694758085; 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=Mw+mzSdrCh9Y5DGC49hd2vxht5biTpPIyW2r+s5t1ok=; b=Qj29yO6FcX1HjRteH0qCHT2h55goOJA98PlKmy/QNScrB+p9MFd4/jTYKHg1qRiotq xXROfnYYXuzykFgIHxSVZV8PuN9642bvhLlAoM33eMeFke8mVKKU+jk/wvWoiBRSBKfy IdeCRYU1yLK9Va19q1zA/xLUhoteNoV5LFGxUO8OglAI88hglueJoQ9V2cUGvdct4L+T U0W7KYf1nrm+cJTvv/c1I10jpz1HAN7pMPNfp82rqhZXQaMVBt8rq88kj/gfLmb6dOaE FrQosrVpqLF15Wtn8Wx1pzkhxkBA6mgxDJBodEAP4nzZPJvPlNxEphQk/gBHMvYpQ8A3 G1Vg== X-Gm-Message-State: AOJu0YyaMwisYUtpq+rMMsusSgF6O84g//pCzUu8VjyRcueWLXjgpOuq sNH76ffWlVMXj3dYiHXyp2yoUWJ6I765Shho X-Google-Smtp-Source: AGHT+IHs3YsyroH9c3I/BpUIUwmAoumNAHTbtlIvxvx33+N4QXXS9fn10xatwiSd3dr8h7xvYM0Agg== X-Received: by 2002:a17:902:e84a:b0:1c3:3cde:7b44 with SMTP id t10-20020a170902e84a00b001c33cde7b44mr2075547plg.12.1694153285463; Thu, 07 Sep 2023 23:08:05 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Alistair Francis , Andrew Jones Subject: [PULL 50/65] target/riscv/cpu.c: split non-ratified exts from riscv_cpu_extensions[] Date: Fri, 8 Sep 2023 16:04:16 +1000 Message-ID: <20230908060431.1903919-51-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::633; envelope-from=alistair23@gmail.com; helo=mail-pl1-x633.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: 1694153306934100001 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza Create a new riscv_cpu_experimental_exts[] to store the non-ratified extensions properties. Once they are ratified we'll move them back to riscv_cpu_extensions[]. riscv_cpu_add_user_properties() and riscv_cpu_add_kvm_properties() are changed to keep adding non-ratified properties to users. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones Message-ID: <20230901194627.1214811-6-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 8662414906..2349f813e4 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1881,8 +1881,11 @@ static Property riscv_cpu_extensions[] =3D { DEFINE_PROP_BOOL("xtheadsync", RISCVCPU, cfg.ext_xtheadsync, false), DEFINE_PROP_BOOL("xventanacondops", RISCVCPU, cfg.ext_XVentanaCondOps,= false), =20 - /* These are experimental so mark with 'x-' */ + DEFINE_PROP_END_OF_LIST(), +}; =20 +/* These are experimental so mark with 'x-' */ +static Property riscv_cpu_experimental_exts[] =3D { /* ePMP 0.9.3 */ DEFINE_PROP_BOOL("x-epmp", RISCVCPU, cfg.epmp, false), DEFINE_PROP_BOOL("x-smaia", RISCVCPU, cfg.ext_smaia, false), @@ -1975,6 +1978,10 @@ static void riscv_cpu_add_kvm_properties(Object *obj) riscv_cpu_add_kvm_unavail_prop(obj, prop->name); } =20 + for (prop =3D riscv_cpu_experimental_exts; prop && prop->name; prop++)= { + riscv_cpu_add_kvm_unavail_prop(obj, prop->name); + } + for (prop =3D riscv_cpu_options; prop && prop->name; prop++) { /* Check if KVM created the property already */ if (object_property_find(obj, prop->name)) { @@ -2014,6 +2021,10 @@ static void riscv_cpu_add_user_properties(Object *ob= j) for (prop =3D riscv_cpu_options; prop && prop->name; prop++) { qdev_property_add_static(dev, prop); } + + for (prop =3D riscv_cpu_experimental_exts; prop && prop->name; prop++)= { + qdev_property_add_static(dev, prop); + } } =20 static Property riscv_cpu_properties[] =3D { --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153323; cv=none; d=zohomail.com; s=zohoarc; b=lCRZYqjDvCl7UnKlKZ1HWSyhZKPDZ6gbY4WX9ixFTwfTzuDA/pd/OgCHB1zFIyG39J0Y+js3KikdnSKthJbNaUrhABt2h6VP3f2ZE8o/G1P2c0BKV/JfH0gBY0oZX9kI2TbTxuQP3SALND7WMCPB3YlqWpMLfi7C2Wt8FYpm7lQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153323; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KlFztUvm68OvuSX22OvpfIWs++5wHP416baD42F1jhg=; b=OD3KcOl+9c0TGvu1r2e9neeQFNN8QvTsoLXWvi/+Qrrk2GWW4KxSOh8PKg5n6b8KLPajZkMgGKLQ9mORGS2kn/F6gd+XPg24LdN1KdXfm8oP0ghPrVGqnc4jgVb6x1KqFRyd45Fd3Pv+hPhGPBx+k/c32zMbiL7hya7+UC7Rz+Y= 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 1694153323948555.1847726906674; Thu, 7 Sep 2023 23:08:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUfD-0002t4-LF; Fri, 08 Sep 2023 02:08:19 -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 1qeUf7-0002X6-G7 for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:14 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUf4-00089Z-Ss for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:13 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1bf078d5f33so15460685ad.3 for ; Thu, 07 Sep 2023 23:08:10 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.08.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:08:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153289; x=1694758089; 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=KlFztUvm68OvuSX22OvpfIWs++5wHP416baD42F1jhg=; b=qkueIwtOiETRe2M4MbgcnDMFBhzhpre+m5S6CfU2DY+P7FgTE7YpxflAJRELWvMgEN BClsSn6u6rnDtrlFAc8jqoDQILxZko2lQWTj9EFo0u4SSgemNeSV6CdqKUyf4rMhPkfO HZvl8Ypm+39D/xVNDL4Wv3H+7x4MwAOB0TuBURnMw8692bEkVo5dDYaT4hGupGN4gRhT Ro4TnjfleDlRZXOgTRi3YMyoVYz7yl23ni+rg2TNpPgzlk0z5SlsBnf4uGnKOaZuU/E5 s2iELKChvnMP19VtIMF5BPjwzd0A4FbGsmw+629jbWO9fRXmUFYY04dGowZeLwm7mRtY 1FYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153289; x=1694758089; 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=KlFztUvm68OvuSX22OvpfIWs++5wHP416baD42F1jhg=; b=m65RU13K197gO/frVzVA03X/P0kziYRdHG1ZN7ONTXSB+BeHRmJMg8ss9UvbRN2cZU Vp5zKV4D4NWQOfkHddq/Mo/mIEI9JtJoaoZ3D7gWUjG508daZolqTRzw+blEIsOYE3B8 R19vvV+Z2YWqIYaEs4HWaycJteTPPEIUZNakf5u3vdnHAI+qOgrlfRieM5Xj2Apyi330 8nZh8djwUbejujMHsMvfIrzTyXwMBeLwV5l4EK/eUPH0aFvEj9MRJXG9nIJhl3gqbdls hyUhI11K+m3TmbzvNNnjLAMR0KhNGNYJB/deICLqOzSJAmusvcwTshU7pJiAN6LSYZwp aonA== X-Gm-Message-State: AOJu0YzWdmocAP2o7iMJr5+ULc46/itpecfPaCyHrjfZZu5m3YR0i2Ik g/j0ckaThjuymz9l4FVMccmHTSMQZGPcx9ks X-Google-Smtp-Source: AGHT+IGo6j281DGcQJugFnvru3YglJ7d1vmO6rQ0A/YyKGNpeCWq1jmGMxgUMoFsBbgnh6d5IM6VdA== X-Received: by 2002:a17:902:9a4b:b0:1c0:bf62:c921 with SMTP id x11-20020a1709029a4b00b001c0bf62c921mr1783490plv.18.1694153289146; Thu, 07 Sep 2023 23:08:09 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Alistair Francis , Andrew Jones Subject: [PULL 51/65] target/riscv/cpu.c: split vendor exts from riscv_cpu_extensions[] Date: Fri, 8 Sep 2023 16:04:17 +1000 Message-ID: <20230908060431.1903919-52-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::636; envelope-from=alistair23@gmail.com; helo=mail-pl1-x636.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: 1694153325311100001 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza Our goal is to make riscv_cpu_extensions[] hold only ratified, non-vendor extensions. Create a new riscv_cpu_vendor_exts[] array for them, changing riscv_cpu_add_user_properties() and riscv_cpu_add_kvm_properties() accordingly. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones Message-ID: <20230901194627.1214811-7-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 2349f813e4..86d536f242 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1867,7 +1867,10 @@ static Property riscv_cpu_extensions[] =3D { DEFINE_PROP_BOOL("zcmt", RISCVCPU, cfg.ext_zcmt, false), DEFINE_PROP_BOOL("zicond", RISCVCPU, cfg.ext_zicond, false), =20 - /* Vendor-specific custom extensions */ + DEFINE_PROP_END_OF_LIST(), +}; + +static Property riscv_cpu_vendor_exts[] =3D { DEFINE_PROP_BOOL("xtheadba", RISCVCPU, cfg.ext_xtheadba, false), DEFINE_PROP_BOOL("xtheadbb", RISCVCPU, cfg.ext_xtheadbb, false), DEFINE_PROP_BOOL("xtheadbs", RISCVCPU, cfg.ext_xtheadbs, false), @@ -1978,6 +1981,10 @@ static void riscv_cpu_add_kvm_properties(Object *obj) riscv_cpu_add_kvm_unavail_prop(obj, prop->name); } =20 + for (prop =3D riscv_cpu_vendor_exts; prop && prop->name; prop++) { + riscv_cpu_add_kvm_unavail_prop(obj, prop->name); + } + for (prop =3D riscv_cpu_experimental_exts; prop && prop->name; prop++)= { riscv_cpu_add_kvm_unavail_prop(obj, prop->name); } @@ -2022,6 +2029,10 @@ static void riscv_cpu_add_user_properties(Object *ob= j) qdev_property_add_static(dev, prop); } =20 + for (prop =3D riscv_cpu_vendor_exts; prop && prop->name; prop++) { + qdev_property_add_static(dev, prop); + } + for (prop =3D riscv_cpu_experimental_exts; prop && prop->name; prop++)= { qdev_property_add_static(dev, prop); } --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153667; cv=none; d=zohomail.com; s=zohoarc; b=lKogqmlrqL2Tbu0nKYMlvEAfeKL7CkCL24dfzujlG7tK5n2iXT+o39jd/dpNXEWBz+wRcsCibzBUtetifPbKdbVjWedyuWM4jBuMuGZhIBxLzK3LzkLKUmP8w+mGh0NJusfYk1AADNK7AVmxLh0IKbqCwUzWWyUVNWMKc0EIV9s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153667; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+dNGiidBvez8oj7Oxa12VP8Kmof+HgNG4C5YkfEeGZ8=; b=Anzxp1VU4+t49N705Xg5VqqUGCFL/ct4OXrvO90LisiKxzr/opsQnRJifQApLUz/DUXlNhik1eNzDNN8d8d8in5QxYbQ1NOImzrcP/Mh8C8Fs7oBPDtwF6E9GEJt8Vw7TcishMFypvDB+q4PQ3Bv86Uq19BURXCceIz048nUEhk= 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 1694153667968721.0959777989029; Thu, 7 Sep 2023 23:14:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUfH-000351-09; Fri, 08 Sep 2023 02:08:23 -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 1qeUfB-0002lw-Of for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:19 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUf8-0008Bi-Vy for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:17 -0400 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-68e2ffd51f2so1457338b3a.2 for ; Thu, 07 Sep 2023 23:08:14 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.08.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:08:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153293; x=1694758093; 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=+dNGiidBvez8oj7Oxa12VP8Kmof+HgNG4C5YkfEeGZ8=; b=ARPHV15S8cU2OFjDXhWrUVBw8zBWCMSYjDitPsKnX+9DlFodl6bE/H/LHtNNt/RfpQ 9o9CSc+RfmxJZAodYcIz/CboOwIfQLUNvh/pXitms81M6l4DJ5sAx4Vkf7CsVnZktYSs 6Y004NYNlpE2t0rrU3cCCjBxXmWPW1dw0VoWbZxP/XP/DUjkHsV6o8+Z1Kh9vgqLiTSR aVtPVZe1YFsIabNeeflG/EEp95xfmV3z8Gg0FPyN+vhA22+jqnqJVFLs/r0XJEunryvN nfwXL8fXqK6Vcj7MrzvAdy34rjr7mwOIZuZBJ/IOsNZ3WU/yfvdaNzOuCdKZ/fXLOdh3 qoEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153293; x=1694758093; 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=+dNGiidBvez8oj7Oxa12VP8Kmof+HgNG4C5YkfEeGZ8=; b=V232bGo50sUozzOdhzbS/iPf8sM83BWfpmpun2YfO9gMBS/9mxWKQ7Dw3Gkl2U5K7K VoPHonBZvqcj4/228/5imlsdI6rmyDqLyLsHo7Tg05DSmfu0P+gsv8La+3bVsBjuVKr0 VqOcmqfhW6JGARUYBI52mFiF7RFN/0RqFxTpCMCg7o/vpCWWy0BU1MNW8qPIbr1KnVn7 +jo9IHRU7NC7Rso4/IwnFi3C3MWkaLUrp/8kdIITD/i6f53wbHQZPWVDTeN78zrznTRN jFPTrg8gOHLh8/dH7CgPxdWT1j8zydsO4L+97/UTJyE/hkhOrtpKacaszbslTLlq5Tn+ 3nLg== X-Gm-Message-State: AOJu0YxDcpqRzp+BYtlYsrljpjDltD1aSFRBevmbBwuipG+5booJzsg7 0gtqCr0085gVLErc0/EBcwNE1MsEomqDsD7q X-Google-Smtp-Source: AGHT+IEWXV5X/SaawBcSFPLb5ZA4dHM3uVCQvG9Y+3SAomlAG1HOUIWzNFGzJRcPo3F39zAiD66bKQ== X-Received: by 2002:a05:6a20:840d:b0:14e:3daf:bef9 with SMTP id c13-20020a056a20840d00b0014e3dafbef9mr2305240pzd.16.1694153292936; Thu, 07 Sep 2023 23:08:12 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Andrew Jones , Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 52/65] target/riscv/cpu.c: add riscv_cpu_add_qdev_prop_array() Date: Fri, 8 Sep 2023 16:04:18 +1000 Message-ID: <20230908060431.1903919-53-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::430; envelope-from=alistair23@gmail.com; helo=mail-pf1-x430.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: 1694153668406100002 From: Daniel Henrique Barboza The code inside riscv_cpu_add_user_properties() became quite repetitive after recent changes. Add a helper to hide the repetition away. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-ID: <20230901194627.1214811-8-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 86d536f242..d484d63bcd 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1951,6 +1951,15 @@ static void cpu_set_cfg_unavailable(Object *obj, Vis= itor *v, } #endif =20 +static void riscv_cpu_add_qdev_prop_array(DeviceState *dev, Property *arra= y) +{ + g_assert(array); + + for (Property *prop =3D array; prop && prop->name; prop++) { + qdev_property_add_static(dev, prop); + } +} + #ifndef CONFIG_USER_ONLY static void riscv_cpu_add_kvm_unavail_prop(Object *obj, const char *prop_n= ame) { @@ -2007,7 +2016,6 @@ static void riscv_cpu_add_kvm_properties(Object *obj) */ static void riscv_cpu_add_user_properties(Object *obj) { - Property *prop; DeviceState *dev =3D DEVICE(obj); =20 #ifndef CONFIG_USER_ONLY @@ -2021,21 +2029,10 @@ static void riscv_cpu_add_user_properties(Object *o= bj) =20 riscv_cpu_add_misa_properties(obj); =20 - for (prop =3D riscv_cpu_extensions; prop && prop->name; prop++) { - qdev_property_add_static(dev, prop); - } - - for (prop =3D riscv_cpu_options; prop && prop->name; prop++) { - qdev_property_add_static(dev, prop); - } - - for (prop =3D riscv_cpu_vendor_exts; prop && prop->name; prop++) { - qdev_property_add_static(dev, prop); - } - - for (prop =3D riscv_cpu_experimental_exts; prop && prop->name; prop++)= { - qdev_property_add_static(dev, prop); - } + riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_extensions); + riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_options); + riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_vendor_exts); + riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_experimental_exts); } =20 static Property riscv_cpu_properties[] =3D { --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153588; cv=none; d=zohomail.com; s=zohoarc; b=VOHgZY1mLQQafy8D7XG1OlIwh1S3yuVnXsPaCEktGIkY6CkasNQxE5h7VSMTykdX+/H1UnASsKUu+UdNdyzYeTS87yZlTvy/U1VHEkQSQ/4h7e6kminz6VReIP2bcTXkSP3czn+k5dxo23SHUY+H/DRQ+1nSG9Ee1KVdrp5i0kw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153588; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xptM3glyFYsB19H1NGctCpEGJfUDxT1CAdTxvjK2c/M=; b=MtL6p4Fw1WDz1577NLpPf4m9dOKakpsAl/Xub5Wt+2tD+dhemKebWjgCoNYEEHtlPCrQ23lZWUDO/aaYEUOUT3TaMXD9WoAkKgxB/7V/GmUIQSpyHbhduby0W4vKWG3jYObQEXCj3p0iyjIgqL/fBHMux8EzJHsH+fYRXPL0tc4= 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 1694153588815868.2057548316234; Thu, 7 Sep 2023 23:13:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUfH-0003PN-Rx; Fri, 08 Sep 2023 02:08:24 -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 1qeUfG-0003Dq-3g for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:22 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUfC-0008CG-6P for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:21 -0400 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1c0d5b16aacso14712615ad.1 for ; Thu, 07 Sep 2023 23:08:17 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.08.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:08:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153296; x=1694758096; 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=xptM3glyFYsB19H1NGctCpEGJfUDxT1CAdTxvjK2c/M=; b=WgXqWwaMAxwWxHIfwcSalUb10va4UMElNZ3xAkfBQ45LYFHsMrKa5U5xgcApmke6OK Zpa7q4dZlB5mk61blo0wNwJAapiN5IH25hxgaAYW9QT1dnxkWLz8wY2+ZQOWIT5uOVK4 gisMnTQkwpqD4adK7Mhl1Rhp2zXJ+efAgU8NScf55G3HM78IRS6HEFQxsGnjCfalxymi 41zhs4p5rPALaF0zjryRJgWSHg5FK6UEu1CgFnZ0BhpZikUWoQAA+RfTot9ND6xQ4gSN N0YaAy0vazyUSAqGA6EaUTOKodOQfAV9AagkA4graMz/LL46D3eVDPS9pXswftipjkqI HLdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153296; x=1694758096; 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=xptM3glyFYsB19H1NGctCpEGJfUDxT1CAdTxvjK2c/M=; b=lLFImzzNJ5E0bIDnN/iHcbWPWok5Y9q6CNHEZtrmraOUub1kCsFr5dMH5phbaZhpYq KFQ5WS+Ef96pxrQyXopx6ClOdV1oFOZBDHPGdghxViton6hJWCZ2dk39KAXePMHemapr RQph6N7czy4ElDcAmzVDx873rsHRiJzLyJbx6885kqLeUqi95phCba5pYGoJc/Hi4ZsE fWFY/4mTaMXYIKTr08pODTb5Ueuw53rb5vS5JmBNvS8ZE26UHdhFh/0l2+dCqKUmYlns SM1KqzlwkCwSWGTQ4V6XtUOiIyNy/CUconHLoNuVEbSgygvfb5hZYfbKN/bO1QnWyuLc 36Wg== X-Gm-Message-State: AOJu0YxHxAe6WvVHeEh6+Av2qf45ax11o7t5ZM36a0G66cevtv+ZOC76 R0+F6k1ZtB01cVT17LNW9yrybcgRp2eHfoP3 X-Google-Smtp-Source: AGHT+IGIlgaZGjYEAUEAW6UfLTM4pyozzJjM9JP1GHEuzaI2h679fPzJ5NUpmG+5nEF3K7UBzfF0OQ== X-Received: by 2002:a17:903:184:b0:1c0:b163:2cc3 with SMTP id z4-20020a170903018400b001c0b1632cc3mr2018732plg.52.1694153296311; Thu, 07 Sep 2023 23:08:16 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Andrew Jones , Alistair Francis Subject: [PULL 53/65] target/riscv/cpu.c: add riscv_cpu_add_kvm_unavail_prop_array() Date: Fri, 8 Sep 2023 16:04:19 +1000 Message-ID: <20230908060431.1903919-54-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::630; envelope-from=alistair23@gmail.com; helo=mail-pl1-x630.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: 1694153590486100001 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza Use a helper in riscv_cpu_add_kvm_properties() to eliminate some of its code repetition. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Reviewed-by: Alistair Francis Message-ID: <20230901194627.1214811-9-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index d484d63bcd..8cd19a9b9c 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1978,6 +1978,16 @@ static void riscv_cpu_add_kvm_unavail_prop(Object *o= bj, const char *prop_name) NULL, (void *)prop_name); } =20 +static void riscv_cpu_add_kvm_unavail_prop_array(Object *obj, + Property *array) +{ + g_assert(array); + + for (Property *prop =3D array; prop && prop->name; prop++) { + riscv_cpu_add_kvm_unavail_prop(obj, prop->name); + } +} + static void riscv_cpu_add_kvm_properties(Object *obj) { Property *prop; @@ -1986,17 +1996,9 @@ static void riscv_cpu_add_kvm_properties(Object *obj) kvm_riscv_init_user_properties(obj); riscv_cpu_add_misa_properties(obj); =20 - for (prop =3D riscv_cpu_extensions; prop && prop->name; prop++) { - riscv_cpu_add_kvm_unavail_prop(obj, prop->name); - } - - for (prop =3D riscv_cpu_vendor_exts; prop && prop->name; prop++) { - riscv_cpu_add_kvm_unavail_prop(obj, prop->name); - } - - for (prop =3D riscv_cpu_experimental_exts; prop && prop->name; prop++)= { - riscv_cpu_add_kvm_unavail_prop(obj, prop->name); - } + riscv_cpu_add_kvm_unavail_prop_array(obj, riscv_cpu_extensions); + riscv_cpu_add_kvm_unavail_prop_array(obj, riscv_cpu_vendor_exts); + riscv_cpu_add_kvm_unavail_prop_array(obj, riscv_cpu_experimental_exts); =20 for (prop =3D riscv_cpu_options; prop && prop->name; prop++) { /* Check if KVM created the property already */ --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153403; cv=none; d=zohomail.com; s=zohoarc; b=CkilSMx1ePOKtA/v07bwUwooADK2+ybqZGycE4TgZ40FiWxR9MDbXSteR6oYa2/5/S89ZFmRXqiKxXJrWDoAXjYdHpuQ/muiAJ8+FoeKu8tmwvwZm8kBBopHFmQtURj2DfwTOzOnlPlNB3HywmRm49Rm+emPE+0jUEMLPQMcp2I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153403; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bcJw2YBF9hVi4EZvjhVffggHOCp+kHpLSU8s1S63DzU=; b=IgIpiYN24lRSFDE9/h8qvhOP8nzAktk7gfc91B0qQzQWQ84+MquzAwC7DaqO2QlcPT89tDQPhJLR+kUDlm4ETio2X5Eo1u9GR0k2PQTB/ew5WMnO6/eQtx7OIRZOrjcs1mCse4OgZY7V5Ih1c2veRjdc+uxPNI3Vs/ejLSGI1IM= 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 169415340387620.562963928598037; Thu, 7 Sep 2023 23:10:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUfL-0003ql-83; Fri, 08 Sep 2023 02:08:27 -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 1qeUfI-0003Zu-Rg for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:24 -0400 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 1qeUfG-0008Cu-DL for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:24 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1c1ff5b741cso15464515ad.2 for ; Thu, 07 Sep 2023 23:08:21 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.08.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:08:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153300; x=1694758100; 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=bcJw2YBF9hVi4EZvjhVffggHOCp+kHpLSU8s1S63DzU=; b=WBWupjwTFP+3t48AmGcNtNhrhsAC+g6S6m4DV2sm7Kv3vZCSq2g1qsoni69KhhR8qZ MCs1br9OK9yG+DfXIg/pF73vTSlXKOvX4ClckTcqNqfaqGIBHMMNSMYFsXhkfOgqOcqc Uu+qFmy8L48nxbNkqZcYXzsGuxpFRMxypGJwZzT8uEiD4WcBxThsIxQQBsnJUQ1wMAbj bXr5lcTxCUGUKLa8oz+Ck25MoHnwxc2sA7j3yL/1YLNGEfcWMgJ31h8kUx+zdmB4msx/ P8SU4wlHT55OT7lg9RZPB3zOYiftlqdaA3kgT6oQbZ7FBso3lmnLPjsBWOAWU2Xauz+D s0EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153300; x=1694758100; 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=bcJw2YBF9hVi4EZvjhVffggHOCp+kHpLSU8s1S63DzU=; b=VQYMuw5pHOJGxAjCyJBEsxcRpmMeHtKIOdV3/HyA81brzcLRM73rHSzjQ1uNA18N3Z y0pzRplPjOKYp8ZPEcPdusgDbnzdcL3cB9e8FYl4nPdQ2KjZZctyQNfOaowuULX7TfSq e0iQS+82YtkQeHL9wTTUHaJz7ABB9PorKUDJXE+puF/A+f1J2w0VR0MmyOpFw5yt3dvV nZOemJKiRXkx5osXjvlvWF9FKgGjhsolfwPXd1OHuo9RD3HpJefofXAkhbOBH13vWON9 yG3/H0BoZL+OYRVX+tmUF0/76HsnAAhB9FWKxfH4+rzyPifFPbs8qqHnX1rNDN+NbVPP m5lQ== X-Gm-Message-State: AOJu0YwOfsczULL2vz3Y+rNScJLs4RkVVRx0fkEztqmaFIDAGKhmiBzR 6uj88E3WPeHAo6x720j9lCg/m3NqaJsCIkpe X-Google-Smtp-Source: AGHT+IH1zeV7dICDYvsFwTh91IApneyetFYXwkikD6zlHZ+bxS5FGIgRE1xhrwMmGzCMqlcHB8/nRw== X-Received: by 2002:a17:902:d484:b0:1bb:77a2:edda with SMTP id c4-20020a170902d48400b001bb77a2eddamr1834642plg.36.1694153300117; Thu, 07 Sep 2023 23:08:20 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Alistair Francis , Weiwei Li Subject: [PULL 54/65] target/riscv/cpu.c: limit cfg->vext_spec log message Date: Fri, 8 Sep 2023 16:04:20 +1000 Message-ID: <20230908060431.1903919-55-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::631; envelope-from=alistair23@gmail.com; helo=mail-pl1-x631.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: 1694153405176100001 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza Inside riscv_cpu_validate_v() we're always throwing a log message if the user didn't set a vector version via 'vext_spec'. We're going to include one case with the 'max' CPU where env->vext_ver will be set in the cpu_init(). But that alone will not stop the "vector version is not specified" message from appearing. The usefulness of this log message is debatable for the generic CPUs, but for a 'max' CPU type, where we are supposed to deliver a CPU model with all features possible, it's strange to force users to set 'vext_spec' to get rid of this message. Change riscv_cpu_validate_v() to not throw this log message if env->vext_ver is already set. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Weiwei Li Message-ID: <20230901194627.1214811-10-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 8cd19a9b9c..3ba92c806b 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -959,8 +959,6 @@ static void riscv_cpu_disas_set_info(CPUState *s, disas= semble_info *info) static void riscv_cpu_validate_v(CPURISCVState *env, RISCVCPUConfig *cfg, Error **errp) { - int vext_version =3D VEXT_VERSION_1_00_0; - if (!is_power_of_2(cfg->vlen)) { error_setg(errp, "Vector extension VLEN must be power of 2"); return; @@ -983,17 +981,18 @@ static void riscv_cpu_validate_v(CPURISCVState *env, = RISCVCPUConfig *cfg, } if (cfg->vext_spec) { if (!g_strcmp0(cfg->vext_spec, "v1.0")) { - vext_version =3D VEXT_VERSION_1_00_0; + env->vext_ver =3D VEXT_VERSION_1_00_0; } else { error_setg(errp, "Unsupported vector spec version '%s'", cfg->vext_spec); return; } - } else { + } else if (env->vext_ver =3D=3D 0) { qemu_log("vector version is not specified, " "use the default value v1.0\n"); + + env->vext_ver =3D VEXT_VERSION_1_00_0; } - env->vext_ver =3D vext_version; } =20 static void riscv_cpu_validate_priv_spec(RISCVCPU *cpu, Error **errp) --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153344; cv=none; d=zohomail.com; s=zohoarc; b=kbTkZOv95WN40C/IwIKWWglwRmN1oVdQRTpdCUUy6C/NWTkcDkr3wJgA8SqP8tZU4mr/rExcPp7hQ0fRjAh7tMNhw42LjX10+TXjddSA0w1PR4I1HKrSOPcfLmRio7Etdyd35pZmrDxbIw2cX6Yij7s9xfoTkbdZL7wTtRxJBaQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153344; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QXgIdXKBzf5Dw5nWkVFYbqoRk5qlb7X0+scVn/Ep3Ag=; b=e3PuL473il00KsM6vtxaagPk6Gu/+Xerxhm9qIToaosCk1pTUHaXYHVe07AKTQFXHCS8V2ah7+ApLRAMWrOi1YCav9iKiGy9HLCixTqffXPb2r8lIacV5jcuwgoOWOA5EdTVRA2l+l8/yhEdICjFbtBr2Whhuet94KaAY7BIWDk= 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 1694153344375933.6929112849881; Thu, 7 Sep 2023 23:09:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUfP-0004UB-36; Fri, 08 Sep 2023 02:08:31 -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 1qeUfM-000465-Ok for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:28 -0400 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 1qeUfK-0008DS-6Q for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:28 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1bf7a6509deso12997145ad.3 for ; Thu, 07 Sep 2023 23:08:25 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.08.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:08:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153304; x=1694758104; 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=QXgIdXKBzf5Dw5nWkVFYbqoRk5qlb7X0+scVn/Ep3Ag=; b=Bqin5Pho5zP2thWjrv91csqLPIqx4jFvFkAjXRDQxd/iFxpZvf0mwzIWgvOLs8+PjQ VtyA+raepqtP//89mULRj8npnILSOd5zahHZRb8O6JZN2OQtcW/V2NTY0BcepiYEVYgq YWc8jN/J1CcJU5Ox6fNIGgr5BcXHat3GlhjqpOVXwAX8K50eFc7eQ8wQMaoUH/iTSdKQ GtWwTo3jxx45d++kclVaeqnniqiBNl0pD97esUqKMsKgV2WjaFkldEMJMtoxDoEHfhyO bZ7Bps54sDrw8bosmRzRxAffOwitmPARB759ZJx4jEVVFmTd7DtVpdW+xKhYjOcWZUSt tZJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153304; x=1694758104; 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=QXgIdXKBzf5Dw5nWkVFYbqoRk5qlb7X0+scVn/Ep3Ag=; b=G2u40Qj8K2IBLjGkgc6INANNHEapsT7V9YfS5eRd+zkTVhBdSo1YKV6NMHN/OEj4AG luOc4pmY3LAllFELC7rvpEiYCWdA5QAeBQdaWstY/4XJ2GVWXtQg6chBpB6Zf+WX+MoX T08g49X20ddjpSNwvBQVchkycIMTySmInGAJvUbbutGk6iFvdnGhQ9uVOVPio937BGPV Vup2cQniBicQexpizb77F2Jucra0YHkWquYHnaenxZy4LGUvThBrY9+PSug08qQ850PE ZJaDf/JSYDi1z/kF7J7X4CqvyxnGreASY1ml2CA3xNs8k8cTReWZj/DOZXy8Cp2a7+8g mHDg== X-Gm-Message-State: AOJu0Yw8CWpGmQg/8yORt1p3is/RHzUykUDYYiUYzTXtOXp/K/sdaJP+ DHRkDkmEJLVKBeiU9fRRpUPAglndLGgLUprH X-Google-Smtp-Source: AGHT+IHepPWMd627BhE0FtxjHt1xC1b6qQ20TUEKmfbqsrP8byyHFuNQSh3DksfgEDp2fdYs/pdfMQ== X-Received: by 2002:a17:902:e84b:b0:1bc:25ed:374 with SMTP id t11-20020a170902e84b00b001bc25ed0374mr1967769plg.49.1694153304076; Thu, 07 Sep 2023 23:08:24 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Weiwei Li , Alistair Francis , Andrew Jones Subject: [PULL 55/65] target/riscv: add 'max' CPU type Date: Fri, 8 Sep 2023 16:04:21 +1000 Message-ID: <20230908060431.1903919-56-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::629; envelope-from=alistair23@gmail.com; helo=mail-pl1-x629.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: 1694153345529100001 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza The 'max' CPU type is used by tooling to determine what's the most capable CPU a current QEMU version implements. Other archs such as ARM implements this type. Let's add it to RISC-V. What we consider "most capable CPU" in this context are related to ratified, non-vendor extensions. This means that we want the 'max' CPU to enable all (possible) ratified extensions by default. The reasoning behind this design is (1) vendor extensions can conflict with each other and we won't play favorities deciding which one is default or not and (2) non-ratified extensions are always prone to changes, not being stable enough to be enabled by default. All this said, we're still not able to enable all ratified extensions due to conflicts between them. Zfinx and all its dependencies aren't enabled because of a conflict with RVF. zce, zcmp and zcmt are also disabled due to RVD conflicts. When running with 64 bits we're also disabling zcf. MISA bits RVG, RVJ and RVV are also being set manually since they're default disabled. This is the resulting 'riscv,isa' DT for this new CPU: rv64imafdcvh_zicbom_zicboz_zicsr_zifencei_zihintpause_zawrs_zfa_ zfh_zfhmin_zca_zcb_zcd_zba_zbb_zbc_zbkb_zbkc_zbkx_zbs_zk_zkn_zknd_ zkne_zknh_zkr_zks_zksed_zksh_zkt_zve32f_zve64f_zve64d_ smstateen_sscofpmf_sstc_svadu_svinval_svnapot_svpbmt Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones Message-ID: <20230901194627.1214811-11-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/cpu-qom.h | 1 + target/riscv/cpu.c | 56 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/target/riscv/cpu-qom.h b/target/riscv/cpu-qom.h index 04af50983e..f3fbe37a2c 100644 --- a/target/riscv/cpu-qom.h +++ b/target/riscv/cpu-qom.h @@ -30,6 +30,7 @@ #define CPU_RESOLVING_TYPE TYPE_RISCV_CPU =20 #define TYPE_RISCV_CPU_ANY RISCV_CPU_TYPE_NAME("any") +#define TYPE_RISCV_CPU_MAX RISCV_CPU_TYPE_NAME("max") #define TYPE_RISCV_CPU_BASE32 RISCV_CPU_TYPE_NAME("rv32") #define TYPE_RISCV_CPU_BASE64 RISCV_CPU_TYPE_NAME("rv64") #define TYPE_RISCV_CPU_BASE128 RISCV_CPU_TYPE_NAME("x-rv128") diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 3ba92c806b..365c2b3b56 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -259,6 +259,7 @@ static const char * const riscv_intr_names[] =3D { }; =20 static void riscv_cpu_add_user_properties(Object *obj); +static void riscv_init_max_cpu_extensions(Object *obj); =20 const char *riscv_cpu_get_trap_name(target_ulong cause, bool async) { @@ -396,6 +397,25 @@ static void riscv_any_cpu_init(Object *obj) cpu->cfg.pmp =3D true; } =20 +static void riscv_max_cpu_init(Object *obj) +{ + RISCVCPU *cpu =3D RISCV_CPU(obj); + CPURISCVState *env =3D &cpu->env; + RISCVMXL mlx =3D MXL_RV64; + +#ifdef TARGET_RISCV32 + mlx =3D MXL_RV32; +#endif + set_misa(env, mlx, 0); + riscv_cpu_add_user_properties(obj); + riscv_init_max_cpu_extensions(obj); + env->priv_ver =3D PRIV_VERSION_LATEST; +#ifndef CONFIG_USER_ONLY + set_satp_mode_max_supported(RISCV_CPU(obj), mlx =3D=3D MXL_RV32 ? + VM_1_10_SV32 : VM_1_10_SV57); +#endif +} + #if defined(TARGET_RISCV64) static void rv64_base_cpu_init(Object *obj) { @@ -2036,6 +2056,41 @@ static void riscv_cpu_add_user_properties(Object *ob= j) riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_experimental_exts); } =20 +/* + * The 'max' type CPU will have all possible ratified + * non-vendor extensions enabled. + */ +static void riscv_init_max_cpu_extensions(Object *obj) +{ + RISCVCPU *cpu =3D RISCV_CPU(obj); + CPURISCVState *env =3D &cpu->env; + Property *prop; + + /* Enable RVG, RVJ and RVV that are disabled by default */ + set_misa(env, env->misa_mxl, env->misa_ext | RVG | RVJ | RVV); + + for (prop =3D riscv_cpu_extensions; prop && prop->name; prop++) { + object_property_set_bool(obj, prop->name, true, NULL); + } + + /* set vector version */ + env->vext_ver =3D VEXT_VERSION_1_00_0; + + /* Zfinx is not compatible with F. Disable it */ + object_property_set_bool(obj, "zfinx", false, NULL); + object_property_set_bool(obj, "zdinx", false, NULL); + object_property_set_bool(obj, "zhinx", false, NULL); + object_property_set_bool(obj, "zhinxmin", false, NULL); + + object_property_set_bool(obj, "zce", false, NULL); + object_property_set_bool(obj, "zcmp", false, NULL); + object_property_set_bool(obj, "zcmt", false, NULL); + + if (env->misa_mxl !=3D MXL_RV32) { + object_property_set_bool(obj, "zcf", false, NULL); + } +} + static Property riscv_cpu_properties[] =3D { DEFINE_PROP_BOOL("debug", RISCVCPU, cfg.debug, true), =20 @@ -2374,6 +2429,7 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { .abstract =3D true, }, DEFINE_DYNAMIC_CPU(TYPE_RISCV_CPU_ANY, riscv_any_cpu_init), + DEFINE_DYNAMIC_CPU(TYPE_RISCV_CPU_MAX, riscv_max_cpu_init), #if defined(CONFIG_KVM) DEFINE_CPU(TYPE_RISCV_CPU_HOST, riscv_host_cpu_init), #endif --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153575; cv=none; d=zohomail.com; s=zohoarc; b=Pxe5Ja8RGC4oArOuVaqyhHexUIY7RqtNdpKTm8jVy7Sd4HUkgYCL/ylpXNxhRkWhcAWsHzE7kLIMl8HkKcXOuko7aL5Md0WiWPOP1sAIm0wg+1f+e5dmjuIeZd0wvRJWFkV1gjFvUfSc5ssT1hY8zOLlgELVHjASYw4wfD1bCjQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153575; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hQ/WFteKBHkLnA786Y2XQH8ZP/LZ81hhOddg+nv0wCs=; b=MHTsiizlx+pPQz2Tx50Podj2pGrwIbpCnwxpQc/YjymeXctaQRhwb2rhC4SYMKrX46uIAGpBWXiSzp6slgp1QBvQZxGS268T+2DGHlSDnbIN2g0n1lDrD92BVHWZXkX25ovW4439EHneFOvW+DmTnuJtpaeDCOOk1cmhO9/LwrA= 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 169415357548051.75273341014929; Thu, 7 Sep 2023 23:12:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUfR-0004uS-Fa; Fri, 08 Sep 2023 02:08:33 -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 1qeUfQ-0004jA-2w for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:32 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUfN-0008Dx-Jc for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:31 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1bf6ea270b2so12855665ad.0 for ; Thu, 07 Sep 2023 23:08:29 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.08.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:08:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153307; x=1694758107; 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=hQ/WFteKBHkLnA786Y2XQH8ZP/LZ81hhOddg+nv0wCs=; b=JhK/N0yreCV7tNb4bdAMZh6QGuRPNSaIpxMMBN4hR6fT1sZdXLO1M3WBElA0+wn+cq SbXvV6wCLpOyXqu44RTItQlWrQpN/3d59hSZ+dge78lnuFT5A2UDX9HfVaVJPcf69f/E LV/gEK1SdBpvhotnDbHlvjOfKRuMEfIwDdSil2lQHPX17weHw0GdXwHVZ54Qlz3Td4PH FKL9FI58JTxh/XE1PP1MP4Uk1a6NyueA4It6gVW6ZWa+NNON0Zlg7sBl+HtqH+9uGOVd mpwvhypeZUHGzLmaYyaYOfLvddhBr3w8L1uTlH92I+AJUOA07r5cIFCPEdTTVGVPt7Tl Jucg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153307; x=1694758107; 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=hQ/WFteKBHkLnA786Y2XQH8ZP/LZ81hhOddg+nv0wCs=; b=ZcK9FOx5Acp1O5W+zALGCTUDtw3iENcq05a7ACz5IWiEAhMpXlMj50MCXYHpNb9/N3 IdgkEpI10QkmGtnYO9xe/4m9FRruh4By0YjiYkt9rQeSnjotXrDyAR6r/KBalkhfD8NA /1UfweqM1STFIrpquE9gOtvcQJ4wLeFWuhfFYRCgV82Qy0lHPV+eEUaCO3d9kG/fpwyV Xs1W2J0EkHFKDMAI25yhCmYIsvx1/Kz/2aB9+dAjK57u54uSe/bw7y0Br/4GQkThzwBC IS7Z7mGqCVBE/NosTUQmbNHWDyk1Ky0XSsdObpJsQp+Xhud3QepR5+lCchhDstBiCtqn G6KQ== X-Gm-Message-State: AOJu0YzR3kFWiGrkkkC8qElb3YE6R4w7KL0xYmI9VKDC8VT28LBtMiVI Zm5gdCS9j6h+QD8DOMqT9tZ5bP2545vX6G15 X-Google-Smtp-Source: AGHT+IGsHd9I9MfpMUwd4AM8F4v/bt/SmdGfGDiKoZOwesfHoiPyq3AINiz+yNOzRAcZfByyciONzQ== X-Received: by 2002:a17:902:8c8d:b0:1b6:649b:92cc with SMTP id t13-20020a1709028c8d00b001b6649b92ccmr1402596plo.69.1694153307621; Thu, 07 Sep 2023 23:08:27 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 56/65] avocado, risc-v: add tuxboot tests for 'max' CPU Date: Fri, 8 Sep 2023 16:04:22 +1000 Message-ID: <20230908060431.1903919-57-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::636; envelope-from=alistair23@gmail.com; helo=mail-pl1-x636.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: 1694153577213100005 From: Daniel Henrique Barboza Add smoke tests to ensure that we'll not break the 'max' CPU type when adding new frozen/ratified RISC-V extensions. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Message-ID: <20230901194627.1214811-12-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- tests/avocado/tuxrun_baselines.py | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/avocado/tuxrun_baselines.py b/tests/avocado/tuxrun_basel= ines.py index e12250eabb..c99bea6c0b 100644 --- a/tests/avocado/tuxrun_baselines.py +++ b/tests/avocado/tuxrun_baselines.py @@ -501,6 +501,38 @@ def test_riscv64(self): =20 self.common_tuxrun(csums=3Dsums) =20 + def test_riscv32_maxcpu(self): + """ + :avocado: tags=3Darch:riscv32 + :avocado: tags=3Dmachine:virt + :avocado: tags=3Dcpu:max + :avocado: tags=3Dtuxboot:riscv32 + """ + sums =3D { "Image" : + "89599407d7334de629a40e7ad6503c73670359eb5f5ae9d686353a3d= 6deccbd5", + "fw_jump.elf" : + "f2ef28a0b77826f79d085d3e4aa686f1159b315eff9099a37046b189= 36676985", + "rootfs.ext4.zst" : + "7168d296d0283238ea73cd5a775b3dd608e55e04c7b92b76ecce31bb= 13108cba" } + + self.common_tuxrun(csums=3Dsums) + + def test_riscv64_maxcpu(self): + """ + :avocado: tags=3Darch:riscv64 + :avocado: tags=3Dmachine:virt + :avocado: tags=3Dcpu:max + :avocado: tags=3Dtuxboot:riscv64 + """ + sums =3D { "Image" : + "cd634badc65e52fb63465ec99e309c0de0369f0841b7d9486f9729e1= 19bac25e", + "fw_jump.elf" : + "6e3373abcab4305fe151b564a4c71110d833c21f2c0a1753b7935459= e36aedcf", + "rootfs.ext4.zst" : + "b18e3a3bdf27be03da0b285e84cb71bf09eca071c3a087b42884b698= 2ed679eb" } + + self.common_tuxrun(csums=3Dsums) + def test_s390(self): """ :avocado: tags=3Darch:s390x --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153438; cv=none; d=zohomail.com; s=zohoarc; b=R8j1gnYatVd5EooyAIaXxZ2mBExmm5WO1T0vRUA8F05qjcro/XzD/8Oyq8B8W22gVNAlsrec1BN7M/iATCFZ4wc35xX1D45aBIQKwVkK1Ujc+M+CbDbtV7np2YIHA0T2vj2AK9yq5CLC+5QxqBFh+Js54JjfJ2zaA94yM2JT0yM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153438; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5NG6CVxF4Al3MmcBIBAkea24sVDiq9pdJ5O7crK3UWw=; b=I8Ds0GjQ6WYT3F6juDiGm2D7OwjI9PNynwSVcahMD5b1pYWU8tejOmT2zu/XZ3qE9NCVLYXsCeikWjytzHnyLKFZ30kxbtVHUvuBNu6AJvdS0zyJBnnn/27z6/8AWNH4yHkFh9mQgGjEj8ih2RhuiUiIWX0nNQmHdwYuhNjF0rk= 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 169415343872484.68170109477092; Thu, 7 Sep 2023 23:10:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUfW-0005e2-HO; Fri, 08 Sep 2023 02:08:38 -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 1qeUfT-0005Dr-W0 for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:36 -0400 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 1qeUfR-0008EA-9c for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:35 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1bee82fad0fso14677295ad.2 for ; Thu, 07 Sep 2023 23:08:32 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.08.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:08:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153311; x=1694758111; 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=5NG6CVxF4Al3MmcBIBAkea24sVDiq9pdJ5O7crK3UWw=; b=H9zCxuTsK/umjtVJ9fqI39c3ZLZqbsecECKGnMZ45GKKs27mAR/dGQHm6OAdaS3gsJ /9Svmf6SrnGHw7L3cpxibX4otOxTvvnMyyDpDah5Dk96UMVggCOzJPrAQqzeVIal+5Xv VhWDKFEk0NwBPHrHpwW6OiPmyzxwUT/SeNrpZUG9oWeCl5na76QcuMlwidOljmpGlvSl wqF/nuLxnbD0SIB+AgyJufunJw6txeMLOY6v86hl80wfBYQHKGdSVAZl61oEdXdtJDeM juxV/s7CPfL4Pb6DJzONBQ5LWc8FH/2UvNG2KSu8lUOy3YPR+29jND/l+opu8I8NdXu+ DJ4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153311; x=1694758111; 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=5NG6CVxF4Al3MmcBIBAkea24sVDiq9pdJ5O7crK3UWw=; b=mVI31K1nfXz/+V79lYdnKm+NQ96YVvaRLvtqGu5yGi8pajdS2TdOPu6HUpLZiEqYt1 Avgm8TjKEcZyJY8gXNJBUNLBavbROx2pj+pxUkHpPoBTyIvZ8wXoBPUlMKkzZVh8mSXo vm+mNPBjMM/tmsq/Hwb2MaX/SaigTPcRoDI0EkKwQxGWRnsjS0LwFBxgfvrD+t2+ldAI 2zMaLwmmq3HZFUXI/LDlTqnwn7Cs69bnF68Y81zF3PiPGJIf4IQN05TUW1GOfK4V111e C+Lq0u5MRQEaEP72bjvlZoAl6I4SBxC/7GgKOTyPHhHLFqIbVel4qG/xZDaHjZX1N14e VJtQ== X-Gm-Message-State: AOJu0YycRKWNmPVO449kH8RXiWUQBjLwg7PCS/jhdcifcJWWzvhRCWEc vzkZTpRDXC4+Qth/JXa0HRFgOvTFoeJzH9JR X-Google-Smtp-Source: AGHT+IFUxgTpQQjkFGsQAoLwr0fOp6j/JtmXfgrvaYvu/KeOj3UIJMOY90bEfKN1ge2ib5Lq4d7IHA== X-Received: by 2002:a17:902:d505:b0:1b8:525a:f685 with SMTP id b5-20020a170902d50500b001b8525af685mr1831584plg.37.1694153311301; Thu, 07 Sep 2023 23:08:31 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Alistair Francis , Andrew Jones , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 57/65] target/riscv: deprecate the 'any' CPU type Date: Fri, 8 Sep 2023 16:04:23 +1000 Message-ID: <20230908060431.1903919-58-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=alistair23@gmail.com; helo=mail-pl1-x631.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: 1694153439983100005 From: Daniel Henrique Barboza The 'any' CPU type was introduced in commit dc5bd18fa5725 ("RISC-V CPU Core Definition"), being around since the beginning. It's not an easy CPU to use: it's undocumented and its name doesn't tell users much about what the CPU is supposed to bring. 'git log' doesn't help us either in knowing what was the original design of this CPU type. The closest we have is a comment from Alistair [1] where he recalls from memory that the 'any' CPU is supposed to behave like the newly added 'max' CPU. He also suggested that the 'any' CPU should be removed. The default CPUs are rv32 and rv64, so removing the 'any' CPU will have impact only on users that might have a script that uses '-cpu any'. And those users are better off using the default CPUs or the new 'max' CPU. We would love to just remove the code and be done with it, but one does not simply remove a feature in QEMU. We'll put the CPU in quarantine first, letting users know that we have the intent of removing it in the future. [1] https://lists.gnu.org/archive/html/qemu-devel/2023-07/msg02891.html Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Message-ID: <20230901194627.1214811-13-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- docs/about/deprecated.rst | 12 ++++++++++++ target/riscv/cpu.c | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index dc4da95329..694b878f36 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -365,6 +365,18 @@ QEMU's ``vhost`` feature, which would eliminate the hi= gh latency costs under which the 9p ``proxy`` backend currently suffers. However as of to date no= body has indicated plans for such kind of reimplementation unfortunately. =20 +RISC-V 'any' CPU type ``-cpu any`` (since 8.2) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The 'any' CPU type was introduced back in 2018 and has been around since t= he +initial RISC-V QEMU port. Its usage has always been unclear: users don't k= now +what to expect from a CPU called 'any', and in fact the CPU does not do an= ything +special that isn't already done by the default CPUs rv32/rv64. + +After the introduction of the 'max' CPU type, RISC-V now has a good covera= ge +of generic CPUs: rv32 and rv64 as default CPUs and 'max' as a feature comp= lete +CPU for both 32 and 64 bit builds. Users are then discouraged to use the '= any' +CPU type starting in 8.2. =20 Block device options '''''''''''''''''''' diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 365c2b3b56..0dae259e02 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1522,6 +1522,11 @@ static void riscv_cpu_realize(DeviceState *dev, Erro= r **errp) RISCVCPUClass *mcc =3D RISCV_CPU_GET_CLASS(dev); Error *local_err =3D NULL; =20 + if (object_dynamic_cast(OBJECT(dev), TYPE_RISCV_CPU_ANY) !=3D NULL) { + warn_report("The 'any' CPU is deprecated and will be " + "removed in the future."); + } + cpu_exec_realizefn(cs, &local_err); if (local_err !=3D NULL) { error_propagate(errp, local_err); --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153404; cv=none; d=zohomail.com; s=zohoarc; b=YKqHj6CSmGvTvIcu9xqrjrCEmgOGFAPsbvPP0DlRMwVbDK3f2UsFqDadS+Ppw2tvMQu4XqPori2qslp3jc2wrDfIJWKgOy8s+4qhIzvVFYD6CCTtutdEgh+XBm6tj4idjzh40Tw3DL4BBHoMJSTsVTkG6hDfzZDVR9B5ea4KR9o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153404; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Jr7URA9g3570blsLy4covRVzNAG6jd179YZF66T+Xds=; b=ahlY1u5ItA8X0YxWYI3BjCI2Y7KKnSMQ83KgAnfPgKSggF8Y1vk1Rtt7zXBJnTmCz9ZzCpulokbQw+4XYUo5NlXb5dhhsCKf6k5zCe9IeMuVXwI06ZHfrXWzGzUNESQvk+vCxj/iLvUDlXVMpERAJ7k/HKO8+6yA68VOJCSkP0U= 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 1694153404121464.5268018985379; Thu, 7 Sep 2023 23:10:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUfY-0005tf-OK; Fri, 08 Sep 2023 02:08:40 -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 1qeUfW-0005hp-Vb for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:39 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUfU-0008ES-GQ for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:38 -0400 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1c1f8aaab9aso14781685ad.1 for ; Thu, 07 Sep 2023 23:08:36 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.08.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:08:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153315; x=1694758115; 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=Jr7URA9g3570blsLy4covRVzNAG6jd179YZF66T+Xds=; b=JfSOwac5nxwKXIRfbK4DjsNMIMR58w2tV6H+Qwinh0rCLmIhcDr5WZa8p+tvkGzROh vzThxDL9vag+20z6EiASSAOglmrwgysFuEQKF9/7u7XfSo26aQ18KXPGiA2Vj5e4CdoQ G0VhuyZt56iSSobJd3n9A2cqm8I3oPo7tHodOEGqErlkMSXir+hZ5RQjqUhLVmJbg8jc EAYtTAXU3rBmciYtlWajnxh38a84GckZ2C1ATOF1RZKry4uoHhyOkkOwV1RT8x0rcmoC GbYPd4yQ6OP/TNBQEZ0UrqLcJ3lmOpekjm/FHW19vAq409mD11EHxppolikrJWTuTox6 T0Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153315; x=1694758115; 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=Jr7URA9g3570blsLy4covRVzNAG6jd179YZF66T+Xds=; b=Isafh2ckJG8e445d81aMn3Ul8pRwTClEOGHXARFciZheB5jdh7TQj0IgFfdi/YfhrT OJGq9QCqgItT8ufPBRLramdHbZqD/SRyEtGihWUX12+h41oj+zApwtP0D8wK5I1yt5cR IYlNCPTbkLT35ZJn9xg/exhqJZ8+B8pXH/+Fn6I/CtqgkHh0DUmp2nmUTokExu0b8iGu 286VgN6xysxpL5Z2v67P8OajymbsmwwxgJAbKiK3LToaYovYXXrPdxIZ+0sNKjnaK5ek vmEj5LDeC2W5r5ZWc0ayXUrD42BmDbguMPImNFBOA5fGJAAlH7GUOkxfQuOl1Yznfv2M gC+Q== X-Gm-Message-State: AOJu0YwHmU5KCtOl2NqQlIQ+RKLqJ0RtNGzI4xVWCEWYOlS2q8oejywu A5QaPQ8FW17zsT6G0zvJZCXJzlDXGq/Y4ZNa X-Google-Smtp-Source: AGHT+IH/WMZP0wZJF2Pp1hscz6JVUjBJRmubFD6Gdv7BL8ngBVjEOlGKzD99q+eEQ1G/9oZBUX7yVw== X-Received: by 2002:a17:902:a5c7:b0:1c0:6dcd:453d with SMTP id t7-20020a170902a5c700b001c06dcd453dmr1545678plq.20.1694153314836; Thu, 07 Sep 2023 23:08:34 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Alistair Francis , Andrew Jones Subject: [PULL 58/65] target/riscv/cpu.c: use offset in isa_ext_is_enabled/update_enabled Date: Fri, 8 Sep 2023 16:04:24 +1000 Message-ID: <20230908060431.1903919-59-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::630; envelope-from=alistair23@gmail.com; helo=mail-pl1-x630.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: 1694153405188100003 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza We'll have future usage for a function where, given an offset of the struct RISCVCPUConfig, the flag is updated to a certain val. Change all existing callers to use edata->ext_enable_offset instead of 'edata'. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones Message-ID: <20230901194627.1214811-14-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 0dae259e02..03e936348a 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -162,18 +162,17 @@ static const struct isa_ext_data isa_edata_arr[] =3D { ISA_EXT_DATA_ENTRY(xventanacondops, PRIV_VERSION_1_12_0, ext_XVentanaC= ondOps), }; =20 -static bool isa_ext_is_enabled(RISCVCPU *cpu, - const struct isa_ext_data *edata) +static bool isa_ext_is_enabled(RISCVCPU *cpu, uint32_t ext_offset) { - bool *ext_enabled =3D (void *)&cpu->cfg + edata->ext_enable_offset; + bool *ext_enabled =3D (void *)&cpu->cfg + ext_offset; =20 return *ext_enabled; } =20 -static void isa_ext_update_enabled(RISCVCPU *cpu, - const struct isa_ext_data *edata, bool = en) +static void isa_ext_update_enabled(RISCVCPU *cpu, uint32_t ext_offset, + bool en) { - bool *ext_enabled =3D (void *)&cpu->cfg + edata->ext_enable_offset; + bool *ext_enabled =3D (void *)&cpu->cfg + ext_offset; =20 *ext_enabled =3D en; } @@ -1045,9 +1044,10 @@ static void riscv_cpu_disable_priv_spec_isa_exts(RIS= CVCPU *cpu) =20 /* Force disable extensions if priv spec version does not match */ for (i =3D 0; i < ARRAY_SIZE(isa_edata_arr); i++) { - if (isa_ext_is_enabled(cpu, &isa_edata_arr[i]) && + if (isa_ext_is_enabled(cpu, isa_edata_arr[i].ext_enable_offset) && (env->priv_ver < isa_edata_arr[i].min_version)) { - isa_ext_update_enabled(cpu, &isa_edata_arr[i], false); + isa_ext_update_enabled(cpu, isa_edata_arr[i].ext_enable_offset, + false); #ifndef CONFIG_USER_ONLY warn_report("disabling %s extension for hart 0x" TARGET_FMT_lx " because privilege spec version does not match", @@ -2346,7 +2346,7 @@ static void riscv_isa_string_ext(RISCVCPU *cpu, char = **isa_str, int i; =20 for (i =3D 0; i < ARRAY_SIZE(isa_edata_arr); i++) { - if (isa_ext_is_enabled(cpu, &isa_edata_arr[i])) { + if (isa_ext_is_enabled(cpu, isa_edata_arr[i].ext_enable_offset)) { new =3D g_strconcat(old, "_", isa_edata_arr[i].name, NULL); g_free(old); old =3D new; --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153536; cv=none; d=zohomail.com; s=zohoarc; b=XQRXwS8WSV32Cff6Jj3WWS1xGLPldXYTChWr9ShnFV6XWf/W+d6wkKHksogxSxUj7qny5g2SzdqUL10yl99N5bPDU9wLL/lOmjprkQvyHH+K+X0qktoC0V5S9UNlFStc0hBQDHM97I9hVw8MTNXLh+USONTHvywKwFxfdC/2Xok= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153536; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/Qu073TjSctnDYoeikMwne9G4Nlj9hLM/T7NvyQrYNY=; b=Dkbhtnr3IyETHTGadZJF/n/N3lIPHNefxaHAfHdUZPhw6dJHU5y8qMVLq+F4zOzx+Av3K6mJ8Hux6kxgUB/UJa3dDqCW1K15C4YLWCcNtDT7vE44rMC8eH3HeMdYFMHfZ19R/vx2pN9tZQjDGs+h37fNPA8jMeZpBJMKaV5UP0I= 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 1694153536959480.71195327989346; Thu, 7 Sep 2023 23:12:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUfc-0006AQ-WC; Fri, 08 Sep 2023 02:08:45 -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 1qeUfa-00063L-Uc for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:43 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUfY-0008Eu-Eg for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:42 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-68c576d35feso1615807b3a.2 for ; Thu, 07 Sep 2023 23:08:40 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.08.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:08:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153318; x=1694758118; 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=/Qu073TjSctnDYoeikMwne9G4Nlj9hLM/T7NvyQrYNY=; b=rJIY9kd9LKqmycWQrpRhvDizeuGzb8L9lxZV2O5DUnJCkszpNBJ8Pr9Frm/YRsgbeD Nnx6b0akK1nBeQKeP6nPNuqikO7bOrCzvPNIZkZ1FMNfJVxbt6i5I302BKGfEnhrK9rb 6QSw09xdlg57arwOVy7eaHYhckv9kCWFwVUsnndx8sgF1nO/YRAoYQuE0gaNeplXYqZn 2YvRw4z8/tuwquvQhCYCfa8DwsSdo3iR7v6g5ETEFAys4ijiFAQbThXPE/SjWP/Rdv2R zydoA8ruAWt6tsq3MtK4QNmtzqTi/3gwiizeYoM5d3iBEjxe4kuDFuq16+7arg0ib4W+ hMqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153318; x=1694758118; 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=/Qu073TjSctnDYoeikMwne9G4Nlj9hLM/T7NvyQrYNY=; b=uDsDgHvctNYFFaS+OzwczGIHmLl9LkQBQ33Wc75ib2jRq8fhG7vQWCl4TvuY9xH67N bVti+ysdv02lGAwksUPHYWfnxNBbx9w83o99VTnEYZRHnDvMOHOSRYhFVrokFw3+74Sq oB53SIlnWd1QIHhZA8wMcXuoLv0aKfQU5PjhgEZ2SJUQclCN5FsbWjOMfymd5ZIQ/ofd zuBestqc/CJt5jDATaI1ehY0cchJuXYLFWfQb/3U4ejdWCqat9RnbWYRGiZ7uS+Pxj73 XfiwHcnlMRLLfxTTJMVzC99OQAO0Mt74nJ/dHw1uzqUNczWafWjtYOlujrc7DdHINhHt Lweg== X-Gm-Message-State: AOJu0YzHk9D5AC1lUwQ/GGKsYt4y/bm7de2ZN0ivVexnLBO2Vnzk3vx2 lwmobJKUJkuTJdxwUvK9JGrHNFkqrygnRXCn X-Google-Smtp-Source: AGHT+IFla0r6tNZsf1vf4xY4oTjwbMDAZRyuRbkCSt34yoya7MnfDIxWTcqOZjohuCmE+5tNY+cqRQ== X-Received: by 2002:a05:6a20:1604:b0:149:122b:6330 with SMTP id l4-20020a056a20160400b00149122b6330mr2398559pzj.10.1694153318627; Thu, 07 Sep 2023 23:08:38 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Alistair Francis , Andrew Jones , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 59/65] target/riscv: make CPUCFG() macro public Date: Fri, 8 Sep 2023 16:04:25 +1000 Message-ID: <20230908060431.1903919-60-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::431; envelope-from=alistair23@gmail.com; helo=mail-pf1-x431.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: 1694153538390100001 From: Daniel Henrique Barboza The RISC-V KVM driver uses a CPUCFG() macro that calculates the offset of a certain field in the struct RISCVCPUConfig. We're going to use this macro in target/riscv/cpu.c as well in the next patches. Make it public. Rename it to CPU_CFG_OFFSET() for more clarity while we're at it. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-ID: <20230901194627.1214811-15-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.h | 2 ++ target/riscv/cpu.c | 2 +- target/riscv/kvm.c | 8 +++----- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 6ea22e0eea..577abcd724 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -62,6 +62,8 @@ const char *riscv_get_misa_ext_name(uint32_t bit); const char *riscv_get_misa_ext_description(uint32_t bit); =20 +#define CPU_CFG_OFFSET(_prop) offsetof(struct RISCVCPUConfig, _prop) + /* Privileged specification version */ enum { PRIV_VERSION_1_10_0 =3D 0, diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 03e936348a..43c68e1792 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -48,7 +48,7 @@ struct isa_ext_data { }; =20 #define ISA_EXT_DATA_ENTRY(_name, _min_ver, _prop) \ - {#_name, _min_ver, offsetof(struct RISCVCPUConfig, _prop)} + {#_name, _min_ver, CPU_CFG_OFFSET(_prop)} =20 /* * From vector_helper.c diff --git a/target/riscv/kvm.c b/target/riscv/kvm.c index c01cfb03f4..14763ec0cd 100644 --- a/target/riscv/kvm.c +++ b/target/riscv/kvm.c @@ -205,10 +205,8 @@ static void kvm_riscv_update_cpu_misa_ext(RISCVCPU *cp= u, CPUState *cs) } } =20 -#define CPUCFG(_prop) offsetof(struct RISCVCPUConfig, _prop) - #define KVM_EXT_CFG(_name, _prop, _reg_id) \ - {.name =3D _name, .offset =3D CPUCFG(_prop), \ + {.name =3D _name, .offset =3D CPU_CFG_OFFSET(_prop), \ .kvm_reg_id =3D _reg_id} =20 static KVMCPUConfig kvm_multi_ext_cfgs[] =3D { @@ -285,13 +283,13 @@ static void kvm_cpu_set_multi_ext_cfg(Object *obj, Vi= sitor *v, =20 static KVMCPUConfig kvm_cbom_blocksize =3D { .name =3D "cbom_blocksize", - .offset =3D CPUCFG(cbom_blocksize), + .offset =3D CPU_CFG_OFFSET(cbom_blocksize), .kvm_reg_id =3D KVM_REG_RISCV_CONFIG_REG(zicbom_block_size) }; =20 static KVMCPUConfig kvm_cboz_blocksize =3D { .name =3D "cboz_blocksize", - .offset =3D CPUCFG(cboz_blocksize), + .offset =3D CPU_CFG_OFFSET(cboz_blocksize), .kvm_reg_id =3D KVM_REG_RISCV_CONFIG_REG(zicboz_block_size) }; =20 --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153481; cv=none; d=zohomail.com; s=zohoarc; b=CcDLMeEVz7LvI5KjNXsyOr3oj8R2EjJHRrvotMjY2FMvYXz2Wq/qE0md2AoR01dYllNUBS0x48nUKOoU3b8dV/elb3ASP3fZWBdYFMUVCzlREupUNY9GiXSyRdXszDITyxHY8e+G6+76LVOJK/djFXJkN+OWFixmUvkucmDt45I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153481; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FjeTfhuxehQRer2U4WGeHFMo635Td6Rnb8XNvF6bkS0=; b=M454XjER6MdJi66xdYUPX0Z6ZJzQq8VTAmgdY1lFn5LZTPvhz3ckhcg8wrYkyd+V/go4ymw5ZgRtbqwWR8wXuVDBfbf1Yy1gzRYgOi3VAFsZQUO8KvJuVaDQt9TVirGlFGzD5FMrQ2sWz7aCQRcQX18Qw+42nh6oOa1lbIBYPLo= 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 1694153481653202.0598081151718; Thu, 7 Sep 2023 23:11:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUfg-0006F9-2O; Fri, 08 Sep 2023 02:08:48 -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 1qeUfe-0006EJ-7z for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:46 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUfb-0008FH-V0 for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:45 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1bf55a81eeaso13163955ad.0 for ; Thu, 07 Sep 2023 23:08:43 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.08.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:08:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153322; x=1694758122; 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=FjeTfhuxehQRer2U4WGeHFMo635Td6Rnb8XNvF6bkS0=; b=eF60RYgnvr4JQ/Sn9ZDDe3fJ66QAwdXVC9gZTUiUNMhP0Y2OvyDvq1wmlmubikTBsN ecTpyuRLONXjW3Gb82A82CmTG4abgsm6t+oZngLOnjdwE2QAcw6/mcaYAdU/whdxTzp7 LP8PzlJIeneG/5As1iIGYJBueEZ/nRLlKO4KnEWCWYLPgp4PJcFQJbNhprrBdlJUCRKu dnQ4Bz11hgT2qy3Xjpe9RHa/bjs1FAvoCVRA16e57mm3Vf/3srgVJReSsxzslpQeRIzF aKm6UNPIYZyrOVif86ml/RtghmnvmAVPC2VvlQPVN9qvZxR8m7QBEeD41dIswucb2xTH /asg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153322; x=1694758122; 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=FjeTfhuxehQRer2U4WGeHFMo635Td6Rnb8XNvF6bkS0=; b=evBKh8fXsoTy6qs4yfCAxBtoX6WVDFoWPopcBoPCI3apDPy01WzuZ4qzIdH/N+QP0/ Z8dZNFm1C0ud7wrQaQzFQbZl/d2hIS6nhSChUZe8QBXerNRaYE6GB1CliPZ+uFMp7H8F 5Shass8kdu1LYdjRf5WTlpjtVTYmL61dAQgUe+b9k2SR6wYNxAjjqVyPzly7AiHKR5Hi x+7UB5JjTc3Gl3DNR2lJ6imEVhasc8fzytPrqmFLe3fYLj4UddWhkEFOrESRtxXAJgGa zkqFCe67vIAzkd+SXQt1l5+nwtFsG59N0rjbFtHrLZwpDUNzqT2yQY1Cx+i3xNpmHmRr /KqQ== X-Gm-Message-State: AOJu0YyXVL6IuJXrWv6iFYuvXnFND0dR2HOKtGGzO9rIo4vRZciloKmS qgZO2C4fDM5ZyBP1B60G5v3WuFs4I7uT6idG X-Google-Smtp-Source: AGHT+IGCApZUxAjPCoL5aLipk8bzCIRGdCQRrkNgfduDLleikTvhsZkfooKWZ0nCyVkwKGEz5V4ZJw== X-Received: by 2002:a17:902:9b8f:b0:1b0:3637:384e with SMTP id y15-20020a1709029b8f00b001b03637384emr1497956plp.25.1694153322023; Thu, 07 Sep 2023 23:08:42 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Alistair Francis , Andrew Jones Subject: [PULL 60/65] target/riscv/cpu.c: introduce cpu_cfg_ext_auto_update() Date: Fri, 8 Sep 2023 16:04:26 +1000 Message-ID: <20230908060431.1903919-61-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::635; envelope-from=alistair23@gmail.com; helo=mail-pl1-x635.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: 1694153483114100005 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza During realize() time we're activating a lot of extensions based on some criteria, e.g.: if (cpu->cfg.ext_zk) { cpu->cfg.ext_zkn =3D true; cpu->cfg.ext_zkr =3D true; cpu->cfg.ext_zkt =3D true; } This practice resulted in at least one case where we ended up enabling something we shouldn't: RVC enabling zca/zcd/zcf when using a CPU that has priv_spec older than 1.12.0. We're also not considering user choice. There's no way of doing it now but this is about to change in the next few patches. cpu_cfg_ext_auto_update() will check for priv version mismatches before enabling extensions. If we have a mismatch between the current priv version and the extension we want to enable, do not enable it. In the near future, this same function will also consider user choice when deciding if we're going to enable/disable an extension or not. For now let's use it to handle zca/zcd/zcf enablement if RVC is enabled. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones Message-ID: <20230901194627.1214811-16-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 43c68e1792..a4876df5f4 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -177,6 +177,43 @@ static void isa_ext_update_enabled(RISCVCPU *cpu, uint= 32_t ext_offset, *ext_enabled =3D en; } =20 +static int cpu_cfg_ext_get_min_version(uint32_t ext_offset) +{ + int i; + + for (i =3D 0; i < ARRAY_SIZE(isa_edata_arr); i++) { + if (isa_edata_arr[i].ext_enable_offset !=3D ext_offset) { + continue; + } + + return isa_edata_arr[i].min_version; + } + + g_assert_not_reached(); +} + +static void cpu_cfg_ext_auto_update(RISCVCPU *cpu, uint32_t ext_offset, + bool value) +{ + CPURISCVState *env =3D &cpu->env; + bool prev_val =3D isa_ext_is_enabled(cpu, ext_offset); + int min_version; + + if (prev_val =3D=3D value) { + return; + } + + if (value && env->priv_ver !=3D PRIV_VERSION_LATEST) { + /* Do not enable it if priv_ver is older than min_version */ + min_version =3D cpu_cfg_ext_get_min_version(ext_offset); + if (env->priv_ver < min_version) { + return; + } + } + + isa_ext_update_enabled(cpu, ext_offset, value); +} + const char * const riscv_int_regnames[] =3D { "x0/zero", "x1/ra", "x2/sp", "x3/gp", "x4/tp", "x5/t0", "x6/t1", "x7/t2", "x8/s0", "x9/s1", "x10/a0", "x11/a1", "x12/a2", "x13/a3", @@ -1268,12 +1305,12 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cp= u, Error **errp) =20 /* zca, zcd and zcf has a PRIV 1.12.0 restriction */ if (riscv_has_ext(env, RVC) && env->priv_ver >=3D PRIV_VERSION_1_12_0)= { - cpu->cfg.ext_zca =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zca), true); if (riscv_has_ext(env, RVF) && env->misa_mxl_max =3D=3D MXL_RV32) { - cpu->cfg.ext_zcf =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcf), true); } if (riscv_has_ext(env, RVD)) { - cpu->cfg.ext_zcd =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcd), true); } } =20 --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153427; cv=none; d=zohomail.com; s=zohoarc; b=e9+mtBr12qfpQY61rVktfYjMO6HKjf13X67rgkKaeMv4tkWPE7rL3Wfy+unA8POCLKojVwyhOrli1GslFF88hODom+qcuQqsCybtb5QyX7ANmKm2rh6J1omda6CN0/epsprFCmXx4lPCt2s1Y8YNs1yWn+ITZztJramNFcKbKZ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153427; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=X3TXakHoXRsT7MrbHl8Tk03e7NcDoueB5M4ZFXLQkgo=; b=IZ2gFLqrieyn7kIMTM7Doa9d8H5g5EtpZ5SqW4T4GR0sQwl5h62R4NRq2DmR07QyGzm8FbtU0lsazIw/v2v50Foi9zR51yHoXc/UpdK2LehukjPb958Lu4ITGlSq9FZuLH0PR02emH2TAoqxhLi1Q9bk6Wltzn6LD6mU/pAWU0U= 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 1694153427858873.2245130698651; Thu, 7 Sep 2023 23:10:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUfi-0006FX-QJ; Fri, 08 Sep 2023 02:08:50 -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 1qeUfh-0006FI-Fr for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:49 -0400 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 1qeUff-0008Fx-2e for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:49 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1bf5c314a57so13649425ad.1 for ; Thu, 07 Sep 2023 23:08:46 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.08.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:08:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153325; x=1694758125; 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=X3TXakHoXRsT7MrbHl8Tk03e7NcDoueB5M4ZFXLQkgo=; b=K8+VKR2L8Su4Df1tYZoKuogiu+C2NgvOT2U+XhtiYRu8gL2ok1GhHGIyGfgVQ9vMLM UPhwZCl9rtI5/AgauBeID1TWopcXw1DapofoxZztrunM6Abtg4T+HKTkzoydM3apfLC2 U4JBgPUw4gtXr8gftEkb3ZlOm1afVL7gVMgZA4hnFqf5Zvk5g5H7y9nSsIk37wBMjQ9O AMXhb6H53G+OWkWkk1HUuHSIAelI2w5TG251/xyOCrYuVg4HCjup3VQOUPBYhF3XcxkH B+pVRPgfTlH0Y29l4ctjaFBA6eybsdbsLZcdQEGq5Zc5CbCtzLN7L2GtbUu85WbsZwhL VSeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153325; x=1694758125; 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=X3TXakHoXRsT7MrbHl8Tk03e7NcDoueB5M4ZFXLQkgo=; b=ZJhCDZlUlNKpSZTwVr9La0G0ALBMr1S01tC5OskHGKi6eA5eF0TsrO+edGeAiiirCB g/n8DkRT1dFZFLSUuPfZ8gDvWcJ7MgtU7+FrA5O+/pAU1Y6zDE0MWje+Dy2fXhgmh4jQ 6i6RzQhew7K162fDSxkmK9EMhrZUJYE9vLqMuGQN0sSqxeyjWepo84Oyz7twsSoJSV81 EidqousrM/Hi5EbgQ67XOb5qMLHEzep9pN6pPe2H97FbhDtf7XazKWCxo+Nx9hHt5RnQ 1pnyzUDOs1Kz92ps5B0X0GWPsXiq4V1NfZxDmqpn8CABeIRm4AvBYRtX2tDfXCxGME79 g+AQ== X-Gm-Message-State: AOJu0YzDgPA83SRP8QFFv3U7/5T44IMRbcR0IqlODu+r7kNUQ+euD21P K87tUWhUNSnEnHrL4Ql4/yHejYsqJBG4Fojc X-Google-Smtp-Source: AGHT+IFI9bHWP6bMhCREv0J0+N4SZ+hcXkTJAFTXlAu3YWaLDtfpEHoGfphGofKZcU3EI1WZOfqFig== X-Received: by 2002:a17:902:c252:b0:1c3:6724:db6f with SMTP id 18-20020a170902c25200b001c36724db6fmr1616930plg.29.1694153325372; Thu, 07 Sep 2023 23:08:45 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Alistair Francis , Andrew Jones Subject: [PULL 61/65] target/riscv/cpu.c: use cpu_cfg_ext_auto_update() during realize() Date: Fri, 8 Sep 2023 16:04:27 +1000 Message-ID: <20230908060431.1903919-62-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::62f; envelope-from=alistair23@gmail.com; helo=mail-pl1-x62f.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: 1694153429818100003 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza Let's change the other instances in realize() where we're enabling an extension based on a certain criteria (e.g. it's a dependency of another extension). We're leaving icsr and ifencei being enabled during RVG for later - we'll want to error out in that case. Every other extension enablement during realize is now done via cpu_cfg_ext_auto_update(). The end goal is that only cpu init() functions will handle extension flags directly via "cpu->cfg.ext_N =3D true|false". Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones Message-ID: <20230901194627.1214811-17-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 50 +++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index a4876df5f4..eeaf69599e 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1193,7 +1193,7 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu,= Error **errp) } =20 if (cpu->cfg.ext_zfh) { - cpu->cfg.ext_zfhmin =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zfhmin), true); } =20 if (cpu->cfg.ext_zfhmin && !riscv_has_ext(env, RVF)) { @@ -1219,17 +1219,17 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cp= u, Error **errp) } =20 /* The V vector extension depends on the Zve64d extension */ - cpu->cfg.ext_zve64d =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zve64d), true); } =20 /* The Zve64d extension depends on the Zve64f extension */ if (cpu->cfg.ext_zve64d) { - cpu->cfg.ext_zve64f =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zve64f), true); } =20 /* The Zve64f extension depends on the Zve32f extension */ if (cpu->cfg.ext_zve64f) { - cpu->cfg.ext_zve32f =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zve32f), true); } =20 if (cpu->cfg.ext_zve64d && !riscv_has_ext(env, RVD)) { @@ -1243,7 +1243,7 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu,= Error **errp) } =20 if (cpu->cfg.ext_zvfh) { - cpu->cfg.ext_zvfhmin =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvfhmin), true); } =20 if (cpu->cfg.ext_zvfhmin && !cpu->cfg.ext_zve32f) { @@ -1273,7 +1273,7 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu,= Error **errp) =20 /* Set the ISA extensions, checks should have happened above */ if (cpu->cfg.ext_zhinx) { - cpu->cfg.ext_zhinxmin =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zca), true); } =20 if ((cpu->cfg.ext_zdinx || cpu->cfg.ext_zhinxmin) && !cpu->cfg.ext_zfi= nx) { @@ -1294,12 +1294,12 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cp= u, Error **errp) } =20 if (cpu->cfg.ext_zce) { - cpu->cfg.ext_zca =3D true; - cpu->cfg.ext_zcb =3D true; - cpu->cfg.ext_zcmp =3D true; - cpu->cfg.ext_zcmt =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zca), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcb), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcmp), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcmt), true); if (riscv_has_ext(env, RVF) && env->misa_mxl_max =3D=3D MXL_RV32) { - cpu->cfg.ext_zcf =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcf), true); } } =20 @@ -1367,26 +1367,26 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cp= u, Error **errp) } =20 if (cpu->cfg.ext_zk) { - cpu->cfg.ext_zkn =3D true; - cpu->cfg.ext_zkr =3D true; - cpu->cfg.ext_zkt =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zkn), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zkr), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zkt), true); } =20 if (cpu->cfg.ext_zkn) { - cpu->cfg.ext_zbkb =3D true; - cpu->cfg.ext_zbkc =3D true; - cpu->cfg.ext_zbkx =3D true; - cpu->cfg.ext_zkne =3D true; - cpu->cfg.ext_zknd =3D true; - cpu->cfg.ext_zknh =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zbkb), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zbkc), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zbkx), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zkne), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zknd), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zknh), true); } =20 if (cpu->cfg.ext_zks) { - cpu->cfg.ext_zbkb =3D true; - cpu->cfg.ext_zbkc =3D true; - cpu->cfg.ext_zbkx =3D true; - cpu->cfg.ext_zksed =3D true; - cpu->cfg.ext_zksh =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zbkb), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zbkc), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zbkx), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zksed), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zksh), true); } =20 /* --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153487; cv=none; d=zohomail.com; s=zohoarc; b=I3pi6djE+VQysDcwKMTF03Tq+jt2Hhx+DxGJzIFXhFNhN4RrEl/IK+myLQjsJ2EQKCdqUJUpVhJN+kEGopCxKKI7SAKcbCaYCp6BHpTKMDt/76BxYfV3csirawdyPHV89j/x5ZH79tjiimVHyRSiGxgEwigEOFU78LpPmnMGVhg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153487; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mzZwMyEK91PgrbyddSTZZ+iAhGyu1JUcWMckTOyKaiE=; b=LJGE5WRQkEGzvyEAw68uDoVuwcnK64NiPWFgdjSU7YIAvuyhC7L0AcaTk5p8jmyVnDQ0s6k2+idzjqIxnqnqQ48lql+JjS5Oc4yvQQ61Def6iAlrWfmzu+/jawmsMKKb9SJtNrqIOYSYG8KNnNEE7bzJdd0Z2zHeArmLLLAyTyg= 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 1694153487276694.7043233460607; Thu, 7 Sep 2023 23:11:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUfo-0006Wr-Fx; Fri, 08 Sep 2023 02:08:56 -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 1qeUfm-0006N0-6L for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:54 -0400 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 1qeUfi-0008GE-TS for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:53 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1c0bae4da38so12138165ad.0 for ; Thu, 07 Sep 2023 23:08:50 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.08.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:08:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153329; x=1694758129; 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=mzZwMyEK91PgrbyddSTZZ+iAhGyu1JUcWMckTOyKaiE=; b=C61N9t2LitWWqZyMfExT8xbTrvUrHp1g4cFuEFV279VLt6J8O0zgs6sfyTpSdtoYTa CAEa8y+bTYwN7Unim0IA7aFks0zx+wIsaaFnm4iMfWBXQ/ayy2q81NEnvqEOYhFzXLkG 05R3KlYBs4hLaGYOfXDPib0Z9h4gX3ohI+aZy9mVL9lAiP32s8AEJ5LOtQAnLLXpMNQ3 iPrcnKeDND1ZGg0mXFTXQYapLM3gRhd4uJ/Fnr/DlAGMiHnom1Id1R93pXOQmPjqISWo n4cEcuY3xYfel1BnCHDXrIgwp9JIRRP5sbsbNMX+7SF7S121BQsWeFnGzGiwiGUjL9Xz KwFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153329; x=1694758129; 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=mzZwMyEK91PgrbyddSTZZ+iAhGyu1JUcWMckTOyKaiE=; b=NIz1QSSMzB6whaZjvuvfO3qp+tnr9Vq2PoJTqI7od7tszp/HzIXNKKQ9uC3BVpLUv5 Dg1l0JzFAa3VxI1WN9WmPqx7VChjGimsUscT3Ec4uBsaZIenV6X0C4+p4jsAtVVDe54k Mw0ez5HSoqepmJMTYJGfCLGngkqj4F2IyxG/8nqYkOBRIa7cHtKUiPKs6Kg022AOV8kf j+nI6sqWylhnmSFwjw8niT90h38AzNXXGNmIXQmEeYVKkC3sl+0fT7939EE7IM3bZ/N+ pEFreb98XyFsFI5eEDIbqUPGL1le6tdEBMrZZ8e4glKvbQYRTewU8vyAGueS/NjD8cmr qqTw== X-Gm-Message-State: AOJu0YzPI5ked0INjj6cZZkvNY2QdIs+Xm1XP4+NhNmsRaqHIu+v48j1 X7mayZKedCpd3wscf48MyjJX2m3E/d0ItBVP X-Google-Smtp-Source: AGHT+IFezyW34TobO42f7aQyAZXbpuYpskudmtY1MFuXRm55z4oocs0p6wueepKPh9MXw0AO/+DlmQ== X-Received: by 2002:a17:902:e748:b0:1b5:674d:2aa5 with SMTP id p8-20020a170902e74800b001b5674d2aa5mr1952252plf.13.1694153329056; Thu, 07 Sep 2023 23:08:49 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Alistair Francis , Andrew Jones Subject: [PULL 62/65] target/riscv/cpu.c: introduce RISCVCPUMultiExtConfig Date: Fri, 8 Sep 2023 16:04:28 +1000 Message-ID: <20230908060431.1903919-63-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::634; envelope-from=alistair23@gmail.com; helo=mail-pl1-x634.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: 1694153489312100023 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza If we want to make better decisions when auto-enabling extensions during realize() we need a way to tell if an user set an extension manually. The RISC-V KVM driver has its own solution via a KVMCPUConfig struct that has an 'user_set' flag that is set during the Property set() callback. The set() callback also does init() time validations based on the current KVM driver capabilities. For TCG we would want a 'user_set' mechanic too, but we would look ad-hoc via cpu_cfg_ext_auto_update() if a certain extension was user set or not. If we copy what was made in the KVM side we would look for 'user_set' for one into 60+ extension structs spreaded in 3 arrays (riscv_cpu_extensions, riscv_cpu_experimental_exts, riscv_cpu_vendor_exts). We'll still need an extension struct but we won't be using the 'user_set' flag: - 'RISCVCPUMultiExtConfig' will be our specialized structure, similar to wh= at we're already doing with the MISA extensions in 'RISCVCPUMisaExtConfig'. DEFINE_PROP_BOOL() for all 3 extensions arrays were replaced by MULTI_EXT_CFG_BOOL(), a macro that will init our specialized struct; - the 'multi_ext_user_opts' hash will be used to store the offset of each extension that the user set via the set() callback, cpu_set_multi_ext_cfg(). For now we're just initializing and populating it - next patch will use it to determine if a certain extension was user set; - cpu_add_multi_ext_prop() is a new helper that will replace the qdev_property_add_static() calls that our macros are doing to populate user properties. The macro was renamed to ADD_CPU_MULTIEXT_PROPS_ARRAY() for clarity. Note that the non-extension properties in riscv_cpu_options[] still need to be declared via qdev(). Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones Message-ID: <20230901194627.1214811-18-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 258 ++++++++++++++++++++++++++++----------------- 1 file changed, 159 insertions(+), 99 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index eeaf69599e..1ca034e6da 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -162,6 +162,9 @@ static const struct isa_ext_data isa_edata_arr[] =3D { ISA_EXT_DATA_ENTRY(xventanacondops, PRIV_VERSION_1_12_0, ext_XVentanaC= ondOps), }; =20 +/* Hash that stores user set extensions */ +static GHashTable *multi_ext_user_opts; + static bool isa_ext_is_enabled(RISCVCPU *cpu, uint32_t ext_offset) { bool *ext_enabled =3D (void *)&cpu->cfg + ext_offset; @@ -1718,6 +1721,8 @@ static void riscv_cpu_init(Object *obj) qdev_init_gpio_in(DEVICE(cpu), riscv_cpu_set_irq, IRQ_LOCAL_MAX + IRQ_LOCAL_GUEST_MAX); #endif /* CONFIG_USER_ONLY */ + + multi_ext_user_opts =3D g_hash_table_new(NULL, g_direct_equal); } =20 typedef struct RISCVCPUMisaExtConfig { @@ -1869,108 +1874,118 @@ static void riscv_cpu_add_misa_properties(Object = *cpu_obj) } } =20 -static Property riscv_cpu_extensions[] =3D { +typedef struct RISCVCPUMultiExtConfig { + const char *name; + uint32_t offset; + bool enabled; +} RISCVCPUMultiExtConfig; + +#define MULTI_EXT_CFG_BOOL(_name, _prop, _defval) \ + {.name =3D _name, .offset =3D CPU_CFG_OFFSET(_prop), \ + .enabled =3D _defval} + +static RISCVCPUMultiExtConfig riscv_cpu_extensions[] =3D { /* Defaults for standard extensions */ - DEFINE_PROP_BOOL("sscofpmf", RISCVCPU, cfg.ext_sscofpmf, false), - DEFINE_PROP_BOOL("Zifencei", RISCVCPU, cfg.ext_ifencei, true), - DEFINE_PROP_BOOL("Zicsr", RISCVCPU, cfg.ext_icsr, true), - DEFINE_PROP_BOOL("Zihintntl", RISCVCPU, cfg.ext_zihintntl, true), - DEFINE_PROP_BOOL("Zihintpause", RISCVCPU, cfg.ext_zihintpause, true), - DEFINE_PROP_BOOL("Zawrs", RISCVCPU, cfg.ext_zawrs, true), - DEFINE_PROP_BOOL("Zfa", RISCVCPU, cfg.ext_zfa, true), - DEFINE_PROP_BOOL("Zfh", RISCVCPU, cfg.ext_zfh, false), - DEFINE_PROP_BOOL("Zfhmin", RISCVCPU, cfg.ext_zfhmin, false), - DEFINE_PROP_BOOL("Zve32f", RISCVCPU, cfg.ext_zve32f, false), - DEFINE_PROP_BOOL("Zve64f", RISCVCPU, cfg.ext_zve64f, false), - DEFINE_PROP_BOOL("Zve64d", RISCVCPU, cfg.ext_zve64d, false), - DEFINE_PROP_BOOL("sstc", RISCVCPU, cfg.ext_sstc, true), - - DEFINE_PROP_BOOL("smstateen", RISCVCPU, cfg.ext_smstateen, false), - DEFINE_PROP_BOOL("svadu", RISCVCPU, cfg.ext_svadu, true), - DEFINE_PROP_BOOL("svinval", RISCVCPU, cfg.ext_svinval, false), - DEFINE_PROP_BOOL("svnapot", RISCVCPU, cfg.ext_svnapot, false), - DEFINE_PROP_BOOL("svpbmt", RISCVCPU, cfg.ext_svpbmt, false), - - DEFINE_PROP_BOOL("zba", RISCVCPU, cfg.ext_zba, true), - DEFINE_PROP_BOOL("zbb", RISCVCPU, cfg.ext_zbb, true), - DEFINE_PROP_BOOL("zbc", RISCVCPU, cfg.ext_zbc, true), - DEFINE_PROP_BOOL("zbkb", RISCVCPU, cfg.ext_zbkb, false), - DEFINE_PROP_BOOL("zbkc", RISCVCPU, cfg.ext_zbkc, false), - DEFINE_PROP_BOOL("zbkx", RISCVCPU, cfg.ext_zbkx, false), - DEFINE_PROP_BOOL("zbs", RISCVCPU, cfg.ext_zbs, true), - DEFINE_PROP_BOOL("zk", RISCVCPU, cfg.ext_zk, false), - DEFINE_PROP_BOOL("zkn", RISCVCPU, cfg.ext_zkn, false), - DEFINE_PROP_BOOL("zknd", RISCVCPU, cfg.ext_zknd, false), - DEFINE_PROP_BOOL("zkne", RISCVCPU, cfg.ext_zkne, false), - DEFINE_PROP_BOOL("zknh", RISCVCPU, cfg.ext_zknh, false), - DEFINE_PROP_BOOL("zkr", RISCVCPU, cfg.ext_zkr, false), - DEFINE_PROP_BOOL("zks", RISCVCPU, cfg.ext_zks, false), - DEFINE_PROP_BOOL("zksed", RISCVCPU, cfg.ext_zksed, false), - DEFINE_PROP_BOOL("zksh", RISCVCPU, cfg.ext_zksh, false), - DEFINE_PROP_BOOL("zkt", RISCVCPU, cfg.ext_zkt, false), - - DEFINE_PROP_BOOL("zdinx", RISCVCPU, cfg.ext_zdinx, false), - DEFINE_PROP_BOOL("zfinx", RISCVCPU, cfg.ext_zfinx, false), - DEFINE_PROP_BOOL("zhinx", RISCVCPU, cfg.ext_zhinx, false), - DEFINE_PROP_BOOL("zhinxmin", RISCVCPU, cfg.ext_zhinxmin, false), - - DEFINE_PROP_BOOL("zicbom", RISCVCPU, cfg.ext_icbom, true), - DEFINE_PROP_BOOL("zicboz", RISCVCPU, cfg.ext_icboz, true), - - DEFINE_PROP_BOOL("zmmul", RISCVCPU, cfg.ext_zmmul, false), - - DEFINE_PROP_BOOL("zca", RISCVCPU, cfg.ext_zca, false), - DEFINE_PROP_BOOL("zcb", RISCVCPU, cfg.ext_zcb, false), - DEFINE_PROP_BOOL("zcd", RISCVCPU, cfg.ext_zcd, false), - DEFINE_PROP_BOOL("zce", RISCVCPU, cfg.ext_zce, false), - DEFINE_PROP_BOOL("zcf", RISCVCPU, cfg.ext_zcf, false), - DEFINE_PROP_BOOL("zcmp", RISCVCPU, cfg.ext_zcmp, false), - DEFINE_PROP_BOOL("zcmt", RISCVCPU, cfg.ext_zcmt, false), - DEFINE_PROP_BOOL("zicond", RISCVCPU, cfg.ext_zicond, false), + MULTI_EXT_CFG_BOOL("sscofpmf", ext_sscofpmf, false), + MULTI_EXT_CFG_BOOL("Zifencei", ext_ifencei, true), + MULTI_EXT_CFG_BOOL("Zicsr", ext_icsr, true), + MULTI_EXT_CFG_BOOL("Zihintntl", ext_zihintntl, true), + MULTI_EXT_CFG_BOOL("Zihintpause", ext_zihintpause, true), + MULTI_EXT_CFG_BOOL("Zawrs", ext_zawrs, true), + MULTI_EXT_CFG_BOOL("Zfa", ext_zfa, true), + MULTI_EXT_CFG_BOOL("Zfh", ext_zfh, false), + MULTI_EXT_CFG_BOOL("Zfhmin", ext_zfhmin, false), + MULTI_EXT_CFG_BOOL("Zve32f", ext_zve32f, false), + MULTI_EXT_CFG_BOOL("Zve64f", ext_zve64f, false), + MULTI_EXT_CFG_BOOL("Zve64d", ext_zve64d, false), + MULTI_EXT_CFG_BOOL("sstc", ext_sstc, true), + + MULTI_EXT_CFG_BOOL("smstateen", ext_smstateen, false), + MULTI_EXT_CFG_BOOL("svadu", ext_svadu, true), + MULTI_EXT_CFG_BOOL("svinval", ext_svinval, false), + MULTI_EXT_CFG_BOOL("svnapot", ext_svnapot, false), + MULTI_EXT_CFG_BOOL("svpbmt", ext_svpbmt, false), + + MULTI_EXT_CFG_BOOL("zba", ext_zba, true), + MULTI_EXT_CFG_BOOL("zbb", ext_zbb, true), + MULTI_EXT_CFG_BOOL("zbc", ext_zbc, true), + MULTI_EXT_CFG_BOOL("zbkb", ext_zbkb, false), + MULTI_EXT_CFG_BOOL("zbkc", ext_zbkc, false), + MULTI_EXT_CFG_BOOL("zbkx", ext_zbkx, false), + MULTI_EXT_CFG_BOOL("zbs", ext_zbs, true), + MULTI_EXT_CFG_BOOL("zk", ext_zk, false), + MULTI_EXT_CFG_BOOL("zkn", ext_zkn, false), + MULTI_EXT_CFG_BOOL("zknd", ext_zknd, false), + MULTI_EXT_CFG_BOOL("zkne", ext_zkne, false), + MULTI_EXT_CFG_BOOL("zknh", ext_zknh, false), + MULTI_EXT_CFG_BOOL("zkr", ext_zkr, false), + MULTI_EXT_CFG_BOOL("zks", ext_zks, false), + MULTI_EXT_CFG_BOOL("zksed", ext_zksed, false), + MULTI_EXT_CFG_BOOL("zksh", ext_zksh, false), + MULTI_EXT_CFG_BOOL("zkt", ext_zkt, false), + + MULTI_EXT_CFG_BOOL("zdinx", ext_zdinx, false), + MULTI_EXT_CFG_BOOL("zfinx", ext_zfinx, false), + MULTI_EXT_CFG_BOOL("zhinx", ext_zhinx, false), + MULTI_EXT_CFG_BOOL("zhinxmin", ext_zhinxmin, false), + + MULTI_EXT_CFG_BOOL("zicbom", ext_icbom, true), + MULTI_EXT_CFG_BOOL("zicboz", ext_icboz, true), + + MULTI_EXT_CFG_BOOL("zmmul", ext_zmmul, false), + + MULTI_EXT_CFG_BOOL("zca", ext_zca, false), + MULTI_EXT_CFG_BOOL("zcb", ext_zcb, false), + MULTI_EXT_CFG_BOOL("zcd", ext_zcd, false), + MULTI_EXT_CFG_BOOL("zce", ext_zce, false), + MULTI_EXT_CFG_BOOL("zcf", ext_zcf, false), + MULTI_EXT_CFG_BOOL("zcmp", ext_zcmp, false), + MULTI_EXT_CFG_BOOL("zcmt", ext_zcmt, false), + MULTI_EXT_CFG_BOOL("zicond", ext_zicond, false), =20 DEFINE_PROP_END_OF_LIST(), }; =20 -static Property riscv_cpu_vendor_exts[] =3D { - DEFINE_PROP_BOOL("xtheadba", RISCVCPU, cfg.ext_xtheadba, false), - DEFINE_PROP_BOOL("xtheadbb", RISCVCPU, cfg.ext_xtheadbb, false), - DEFINE_PROP_BOOL("xtheadbs", RISCVCPU, cfg.ext_xtheadbs, false), - DEFINE_PROP_BOOL("xtheadcmo", RISCVCPU, cfg.ext_xtheadcmo, false), - DEFINE_PROP_BOOL("xtheadcondmov", RISCVCPU, cfg.ext_xtheadcondmov, fal= se), - DEFINE_PROP_BOOL("xtheadfmemidx", RISCVCPU, cfg.ext_xtheadfmemidx, fal= se), - DEFINE_PROP_BOOL("xtheadfmv", RISCVCPU, cfg.ext_xtheadfmv, false), - DEFINE_PROP_BOOL("xtheadmac", RISCVCPU, cfg.ext_xtheadmac, false), - DEFINE_PROP_BOOL("xtheadmemidx", RISCVCPU, cfg.ext_xtheadmemidx, false= ), - DEFINE_PROP_BOOL("xtheadmempair", RISCVCPU, cfg.ext_xtheadmempair, fal= se), - DEFINE_PROP_BOOL("xtheadsync", RISCVCPU, cfg.ext_xtheadsync, false), - DEFINE_PROP_BOOL("xventanacondops", RISCVCPU, cfg.ext_XVentanaCondOps,= false), +static RISCVCPUMultiExtConfig riscv_cpu_vendor_exts[] =3D { + MULTI_EXT_CFG_BOOL("xtheadba", ext_xtheadba, false), + MULTI_EXT_CFG_BOOL("xtheadbb", ext_xtheadbb, false), + MULTI_EXT_CFG_BOOL("xtheadbs", ext_xtheadbs, false), + MULTI_EXT_CFG_BOOL("xtheadcmo", ext_xtheadcmo, false), + MULTI_EXT_CFG_BOOL("xtheadcondmov", ext_xtheadcondmov, false), + MULTI_EXT_CFG_BOOL("xtheadfmemidx", ext_xtheadfmemidx, false), + MULTI_EXT_CFG_BOOL("xtheadfmv", ext_xtheadfmv, false), + MULTI_EXT_CFG_BOOL("xtheadmac", ext_xtheadmac, false), + MULTI_EXT_CFG_BOOL("xtheadmemidx", ext_xtheadmemidx, false), + MULTI_EXT_CFG_BOOL("xtheadmempair", ext_xtheadmempair, false), + MULTI_EXT_CFG_BOOL("xtheadsync", ext_xtheadsync, false), + MULTI_EXT_CFG_BOOL("xventanacondops", ext_XVentanaCondOps, false), =20 DEFINE_PROP_END_OF_LIST(), }; =20 /* These are experimental so mark with 'x-' */ -static Property riscv_cpu_experimental_exts[] =3D { +static RISCVCPUMultiExtConfig riscv_cpu_experimental_exts[] =3D { /* ePMP 0.9.3 */ - DEFINE_PROP_BOOL("x-epmp", RISCVCPU, cfg.epmp, false), - DEFINE_PROP_BOOL("x-smaia", RISCVCPU, cfg.ext_smaia, false), - DEFINE_PROP_BOOL("x-ssaia", RISCVCPU, cfg.ext_ssaia, false), + MULTI_EXT_CFG_BOOL("x-epmp", epmp, false), + MULTI_EXT_CFG_BOOL("x-smaia", ext_smaia, false), + MULTI_EXT_CFG_BOOL("x-ssaia", ext_ssaia, false), =20 - DEFINE_PROP_BOOL("x-zvfh", RISCVCPU, cfg.ext_zvfh, false), - DEFINE_PROP_BOOL("x-zvfhmin", RISCVCPU, cfg.ext_zvfhmin, false), + MULTI_EXT_CFG_BOOL("x-zvfh", ext_zvfh, false), + MULTI_EXT_CFG_BOOL("x-zvfhmin", ext_zvfhmin, false), =20 - DEFINE_PROP_BOOL("x-zfbfmin", RISCVCPU, cfg.ext_zfbfmin, false), - DEFINE_PROP_BOOL("x-zvfbfmin", RISCVCPU, cfg.ext_zvfbfmin, false), - DEFINE_PROP_BOOL("x-zvfbfwma", RISCVCPU, cfg.ext_zvfbfwma, false), + MULTI_EXT_CFG_BOOL("x-zfbfmin", ext_zfbfmin, false), + MULTI_EXT_CFG_BOOL("x-zvfbfmin", ext_zvfbfmin, false), + MULTI_EXT_CFG_BOOL("x-zvfbfwma", ext_zvfbfwma, false), =20 /* Vector cryptography extensions */ - DEFINE_PROP_BOOL("x-zvbb", RISCVCPU, cfg.ext_zvbb, false), - DEFINE_PROP_BOOL("x-zvbc", RISCVCPU, cfg.ext_zvbc, false), - DEFINE_PROP_BOOL("x-zvkg", RISCVCPU, cfg.ext_zvkg, false), - DEFINE_PROP_BOOL("x-zvkned", RISCVCPU, cfg.ext_zvkned, false), - DEFINE_PROP_BOOL("x-zvknha", RISCVCPU, cfg.ext_zvknha, false), - DEFINE_PROP_BOOL("x-zvknhb", RISCVCPU, cfg.ext_zvknhb, false), - DEFINE_PROP_BOOL("x-zvksed", RISCVCPU, cfg.ext_zvksed, false), - DEFINE_PROP_BOOL("x-zvksh", RISCVCPU, cfg.ext_zvksh, false), + MULTI_EXT_CFG_BOOL("x-zvbb", ext_zvbb, false), + MULTI_EXT_CFG_BOOL("x-zvbc", ext_zvbc, false), + MULTI_EXT_CFG_BOOL("x-zvkg", ext_zvkg, false), + MULTI_EXT_CFG_BOOL("x-zvkned", ext_zvkned, false), + MULTI_EXT_CFG_BOOL("x-zvknha", ext_zvknha, false), + MULTI_EXT_CFG_BOOL("x-zvknhb", ext_zvknhb, false), + MULTI_EXT_CFG_BOOL("x-zvksed", ext_zvksed, false), + MULTI_EXT_CFG_BOOL("x-zvksh", ext_zvksh, false), =20 DEFINE_PROP_END_OF_LIST(), }; @@ -1993,6 +2008,49 @@ static Property riscv_cpu_options[] =3D { DEFINE_PROP_END_OF_LIST(), }; =20 +static void cpu_set_multi_ext_cfg(Object *obj, Visitor *v, const char *nam= e, + void *opaque, Error **errp) +{ + const RISCVCPUMultiExtConfig *multi_ext_cfg =3D opaque; + bool value; + + if (!visit_type_bool(v, name, &value, errp)) { + return; + } + + isa_ext_update_enabled(RISCV_CPU(obj), multi_ext_cfg->offset, value); + + g_hash_table_insert(multi_ext_user_opts, + GUINT_TO_POINTER(multi_ext_cfg->offset), + (gpointer)value); +} + +static void cpu_get_multi_ext_cfg(Object *obj, Visitor *v, const char *nam= e, + void *opaque, Error **errp) +{ + const RISCVCPUMultiExtConfig *multi_ext_cfg =3D opaque; + bool value =3D isa_ext_is_enabled(RISCV_CPU(obj), multi_ext_cfg->offse= t); + + visit_type_bool(v, name, &value, errp); +} + +static void cpu_add_multi_ext_prop(Object *cpu_obj, + RISCVCPUMultiExtConfig *multi_cfg) +{ + object_property_add(cpu_obj, multi_cfg->name, "bool", + cpu_get_multi_ext_cfg, + cpu_set_multi_ext_cfg, + NULL, (void *)multi_cfg); + + /* + * Set def val directly instead of using + * object_property_set_bool() to save the set() + * callback hash for user inputs. + */ + isa_ext_update_enabled(RISCV_CPU(cpu_obj), multi_cfg->offset, + multi_cfg->enabled); +} + #ifndef CONFIG_USER_ONLY static void cpu_set_cfg_unavailable(Object *obj, Visitor *v, const char *name, @@ -2012,12 +2070,13 @@ static void cpu_set_cfg_unavailable(Object *obj, Vi= sitor *v, } #endif =20 -static void riscv_cpu_add_qdev_prop_array(DeviceState *dev, Property *arra= y) +static void riscv_cpu_add_multiext_prop_array(Object *obj, + RISCVCPUMultiExtConfig *arra= y) { g_assert(array); =20 - for (Property *prop =3D array; prop && prop->name; prop++) { - qdev_property_add_static(dev, prop); + for (RISCVCPUMultiExtConfig *prop =3D array; prop && prop->name; prop+= +) { + cpu_add_multi_ext_prop(obj, prop); } } =20 @@ -2040,11 +2099,11 @@ static void riscv_cpu_add_kvm_unavail_prop(Object *= obj, const char *prop_name) } =20 static void riscv_cpu_add_kvm_unavail_prop_array(Object *obj, - Property *array) + RISCVCPUMultiExtConfig *a= rray) { g_assert(array); =20 - for (Property *prop =3D array; prop && prop->name; prop++) { + for (RISCVCPUMultiExtConfig *prop =3D array; prop && prop->name; prop+= +) { riscv_cpu_add_kvm_unavail_prop(obj, prop->name); } } @@ -2079,8 +2138,6 @@ static void riscv_cpu_add_kvm_properties(Object *obj) */ static void riscv_cpu_add_user_properties(Object *obj) { - DeviceState *dev =3D DEVICE(obj); - #ifndef CONFIG_USER_ONLY riscv_add_satp_mode_properties(obj); =20 @@ -2092,10 +2149,13 @@ static void riscv_cpu_add_user_properties(Object *o= bj) =20 riscv_cpu_add_misa_properties(obj); =20 - riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_extensions); - riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_options); - riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_vendor_exts); - riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_experimental_exts); + riscv_cpu_add_multiext_prop_array(obj, riscv_cpu_extensions); + riscv_cpu_add_multiext_prop_array(obj, riscv_cpu_vendor_exts); + riscv_cpu_add_multiext_prop_array(obj, riscv_cpu_experimental_exts); + + for (Property *prop =3D riscv_cpu_options; prop && prop->name; prop++)= { + qdev_property_add_static(DEVICE(obj), prop); + } } =20 /* @@ -2106,7 +2166,7 @@ static void riscv_init_max_cpu_extensions(Object *obj) { RISCVCPU *cpu =3D RISCV_CPU(obj); CPURISCVState *env =3D &cpu->env; - Property *prop; + RISCVCPUMultiExtConfig *prop; =20 /* Enable RVG, RVJ and RVV that are disabled by default */ set_misa(env, env->misa_mxl, env->misa_ext | RVG | RVJ | RVV); --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153693; cv=none; d=zohomail.com; s=zohoarc; b=JWBZVb6KqtDhzBh+9EXbMin8kyuCUbV8ICz0NbYhVmkoZfwF9dq9QGJ1QyljnFEBm5TOIYMUzEIAIpM0wZpCp+slRWhi7dfvYLyF8pAEx/kEv4hBA/aWaaUJB94lKimcqvg+NST1CcC66GQtJgXmBF+7eFIpUnXOLSv1SBMaqlc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153693; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bzaVsEALV8Dw/FV9PqHI7cUMw8HNiCbwtOvDkljywu0=; b=B9RitqidOjWCZJponvl5GzqVvV7oXErfLUZzUuNJe6iaIDUpZxqGXbcHT90Cz+qZOzDfMlNL0UmoihFiSZ87t/pDa/pn50EZ4DIh4u+9QEdl2jctJiWIjuJGQNlvOhXSGM8h6A6hb8eu1jf+hhxpiMmldWTXwbd/iMPspJIBnWo= 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 1694153693106136.85475835943498; Thu, 7 Sep 2023 23:14:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUfp-0006j5-VH; Fri, 08 Sep 2023 02:08:58 -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 1qeUfo-0006Wt-Ep for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:56 -0400 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 1qeUfm-0008GP-3H for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:56 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1bee82fad0fso14679565ad.2 for ; Thu, 07 Sep 2023 23:08:53 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.08.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:08:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153332; x=1694758132; 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=bzaVsEALV8Dw/FV9PqHI7cUMw8HNiCbwtOvDkljywu0=; b=h8GKG6rF2tDSzxydMKJHP/hsirYSnpdUoArcC6azst1MdamBOq/N1Zaw4CYs76rLWV zqC1KS54O5i+qapNWmBvCRI0CgTn7Laa5mD4iDzvgKzWqMFL2eABWVTxX6AKkYDbZUd5 3Xam5v1nvbMPA4lxyyA62tO+0rlOAPn8iKFeqM0fQ87vccPZ2BW7cHZfOTa5aLsGEdo+ IgC6DDw2MW4wBXZwv8LkoXg0mW8LIDSd/CiWXx4/cPybdcKCjFf86rNl+bFXlagAJSQv juUcZWLV+SQHNHpUwQC60W4AyUwZhbsYSOW5r0NqPYtfJ18yHz/3fcvlKI1hsQExgn1r JOGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153332; x=1694758132; 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=bzaVsEALV8Dw/FV9PqHI7cUMw8HNiCbwtOvDkljywu0=; b=v5UDhlJsCi0lpkBlYkX4KngcRgfwKlz0SkbsDtX9B2744UGm9Kl3Pgzi7yHXWPe2zh 9oT9OPWExkWE7tysv3WUdCkU/vsXqBgIPbAlnOmUKpjklb8/FWT/R1O34Ha7b1N0XoFN 294RmQuofhFtHKma0vlH3/5MaokhtnnsoUyLCQpQYORXRjqjOoYi0+mCjSf+aKmXOuVs opD7ZTbAGjgB5CnGK4WNcU0S0jeuWBE2PH1JPciXI4ynG/GPIsi0KxdwxElSBLvyiycE dRhKSKsuQnkaoPCYKtGiUy6cXVBaoILMD/0hvg+6z819uupUHXwMM/Qv4tho/333JaiP MAPg== X-Gm-Message-State: AOJu0Yxd1NjxkMRtaw3CnANLRtsINwwtWj6DvAxpaHul0/t4Jn3EGUR5 j5Ex3SvkIaVC5EtioIlEHkRmwiQ9MoBWhDB2 X-Google-Smtp-Source: AGHT+IG3d5HxUSzY6kmdw7AV5cuZ2nuxQMhCrqJ1q5QM0ibom8HS2WECIUjjaMcn+SvMRToOS4DlSg== X-Received: by 2002:a17:902:8202:b0:1bf:6ad7:2286 with SMTP id x2-20020a170902820200b001bf6ad72286mr1506035pln.43.1694153332456; Thu, 07 Sep 2023 23:08:52 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Alistair Francis , Andrew Jones Subject: [PULL 63/65] target/riscv: use isa_ext_update_enabled() in init_max_cpu_extensions() Date: Fri, 8 Sep 2023 16:04:29 +1000 Message-ID: <20230908060431.1903919-64-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::62d; envelope-from=alistair23@gmail.com; helo=mail-pl1-x62d.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: 1694153694996100001 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza Before adding support to detect if an extension was user set we need to handle how we're enabling extensions in riscv_init_max_cpu_extensions(). object_property_set_bool() calls the set() callback for the property, and we're going to use this callback to set the 'multi_ext_user_opts' hash. This means that, as is today, all extensions we're setting for the 'max' CPU will be seen as user set in the future. Let's change set_bool() to isa_ext_update_enabled() that will just enable/disable the flag on a certain offset. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones Message-ID: <20230901194627.1214811-19-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 1ca034e6da..617b861258 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -2172,24 +2172,24 @@ static void riscv_init_max_cpu_extensions(Object *o= bj) set_misa(env, env->misa_mxl, env->misa_ext | RVG | RVJ | RVV); =20 for (prop =3D riscv_cpu_extensions; prop && prop->name; prop++) { - object_property_set_bool(obj, prop->name, true, NULL); + isa_ext_update_enabled(cpu, prop->offset, true); } =20 /* set vector version */ env->vext_ver =3D VEXT_VERSION_1_00_0; =20 /* Zfinx is not compatible with F. Disable it */ - object_property_set_bool(obj, "zfinx", false, NULL); - object_property_set_bool(obj, "zdinx", false, NULL); - object_property_set_bool(obj, "zhinx", false, NULL); - object_property_set_bool(obj, "zhinxmin", false, NULL); + isa_ext_update_enabled(cpu, CPU_CFG_OFFSET(ext_zfinx), false); + isa_ext_update_enabled(cpu, CPU_CFG_OFFSET(ext_zdinx), false); + isa_ext_update_enabled(cpu, CPU_CFG_OFFSET(ext_zhinx), false); + isa_ext_update_enabled(cpu, CPU_CFG_OFFSET(ext_zhinxmin), false); =20 - object_property_set_bool(obj, "zce", false, NULL); - object_property_set_bool(obj, "zcmp", false, NULL); - object_property_set_bool(obj, "zcmt", false, NULL); + isa_ext_update_enabled(cpu, CPU_CFG_OFFSET(ext_zce), false); + isa_ext_update_enabled(cpu, CPU_CFG_OFFSET(ext_zcmp), false); + isa_ext_update_enabled(cpu, CPU_CFG_OFFSET(ext_zcmt), false); =20 if (env->misa_mxl !=3D MXL_RV32) { - object_property_set_bool(obj, "zcf", false, NULL); + isa_ext_update_enabled(cpu, CPU_CFG_OFFSET(ext_zcf), false); } } =20 --=20 2.41.0 From nobody Thu Nov 28 07:57:11 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=1694153656; cv=none; d=zohomail.com; s=zohoarc; b=Ue5WXP6veZsdRHZ79m4DJAX8MSW3BLOI5xom+lvwzP7rDuaSp/8QWPI7RF20p//9qBAz+Bez9ucm/H9miuNL95U81A0MRihmISpTP2SaEIHugRzFvA2LWgA3w5BpCcEryGQETQUHcMiEGuC1Gwrj8pu3KLEao1H5lDFfv91VaFU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153656; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4999Ax6xk9vLcdpOVew5ohG5mMllXkx8uzAH+l1br7Q=; b=X8RyEh3fJJgpLmwn5BPcSLIBTz0MtOaRiWxj4hh3xmtoUCAbEP7zkLcxKgt8+iexe1lJvQtmvMXlMwxB663yzsrfb2ZWerDYzJN6NS2SFF8ZCkr9Rq0jx16wxNOTRjR3zoReC/RQQdvw6EQFgdFKtR6uJ06FOBl70z6fm/vILYo= 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 169415365617087.42370130987968; Thu, 7 Sep 2023 23:14:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUft-00076C-HB; Fri, 08 Sep 2023 02:09:01 -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 1qeUfs-0006xI-1n for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:09:00 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUfp-0008Gx-LP for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:08:59 -0400 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1bc8a2f71eeso14858135ad.0 for ; Thu, 07 Sep 2023 23:08:57 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.08.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:08:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153336; x=1694758136; 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=4999Ax6xk9vLcdpOVew5ohG5mMllXkx8uzAH+l1br7Q=; b=pKrr5fnsFjBTP+ijXlN1J5V5LyIJNemw1AqDuxwPuo/llk7wepKKrlAGHRs5eKaTN7 7ToloRjiOueCqMzvHGIeKQ6rDgHvuaU8YVi43csUhqOBkuzv7usoXZZ8I1i7tmL7F1y5 s4NCnccz+tB29TvtYxgQ0vj4+5da1lkTRwSU4+aTIQ1d9r2uDK1ZHBPScgjmIoJl4x03 E+WxA9RdcFakPrsbnVKglvLN+qYcXxogYdKHQBEnVvrCQE62BQ7Gn2k60feoi9r/OQ69 awj9KZPTx6gaIJYPDFbh6b96TkjGHkSp90Nq3vRDdtYCe6kE/Cp3EmnU85egI01Tw9Ss y7MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153336; x=1694758136; 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=4999Ax6xk9vLcdpOVew5ohG5mMllXkx8uzAH+l1br7Q=; b=NKGbGSoAddPBD4QcIL6iW4oIRCxT6JgiFkvE/EDekwwXI13m7ZWNWBzd3epTSDmEue ZQ7Dgb4rITcqacgXlBdtd2MRpjxNkPNRDkYbGGbBszD0TR8KXk+egyUGFetxZIyDWwcA JYhcyWu+SO1PJbVlAlXyZpo4fkhpIR+TnP4D9xnydRBVgQzgzkY77VOEYz38tuaWIQn4 LJ0P66FUj50dWsEYMsaLr39yKgLUWfbKT7+8Gfr1eaI1BMb9tuIDDbT5mHAw3eVSIzyZ a0dQBpWPYGiPVE+n9O7w/wggiHVqpm3dQekscR4WIZIX/1eTmSL5MDiTkaqBPEQysljE 8cHw== X-Gm-Message-State: AOJu0YzwY2RwOV+X4HNkyNkAcJAq6HTZKFDsJXbyzxDPDksbphsEkZKR fzXA1IcJIHpAlMiI25x7NPPqf9ErzgtzGFIY X-Google-Smtp-Source: AGHT+IEKletcIOICqqrrS9vkL+VA/Ei4at2+iN2i+z+MRfyefKUwxglVkbExMZ0Ogy7yjR90+CdG2w== X-Received: by 2002:a17:902:ea0a:b0:1bb:b30e:4364 with SMTP id s10-20020a170902ea0a00b001bbb30e4364mr2054692plg.39.1694153335908; Thu, 07 Sep 2023 23:08:55 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Alistair Francis , Andrew Jones Subject: [PULL 64/65] target/riscv/cpu.c: honor user choice in cpu_cfg_ext_auto_update() Date: Fri, 8 Sep 2023 16:04:30 +1000 Message-ID: <20230908060431.1903919-65-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::636; envelope-from=alistair23@gmail.com; helo=mail-pl1-x636.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: 1694153657195100003 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza Add a new cpu_cfg_ext_is_user_set() helper to check if an extension was set by the user in the command line. Use it inside cpu_cfg_ext_auto_update() to verify if the user set a certain extension and, if that's the case, do not change its value. This will make us honor user choice instead of overwriting the values. Users will then be informed whether they're using an incompatible set of extensions instead of QEMU setting a magic value that works. The reason why we're not implementing user choice for MISA extensions right now is because, today, we do not silently change any MISA bit during realize() time (we do warn when enabling bits if RVG is enabled). We do that - a lot - with multi-letter extensions though, so we're handling the most immediate concern first. After this patch, we'll now error out if the user explicitly set 'zce' to t= rue and 'zca' to false: $ ./build/qemu-system-riscv64 -M virt -cpu rv64,zce=3Dtrue,zca=3Dfalse -nog= raphic qemu-system-riscv64: Zcf/Zcd/Zcb/Zcmp/Zcmt extensions require Zca extension This didn't happen before because we were enabling 'zca' if 'zce' was enabl= ed regardless if the user set 'zca' to false. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones Message-ID: <20230901194627.1214811-20-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 617b861258..78382cb5f2 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -195,6 +195,12 @@ static int cpu_cfg_ext_get_min_version(uint32_t ext_of= fset) g_assert_not_reached(); } =20 +static bool cpu_cfg_ext_is_user_set(uint32_t ext_offset) +{ + return g_hash_table_contains(multi_ext_user_opts, + GUINT_TO_POINTER(ext_offset)); +} + static void cpu_cfg_ext_auto_update(RISCVCPU *cpu, uint32_t ext_offset, bool value) { @@ -206,6 +212,10 @@ static void cpu_cfg_ext_auto_update(RISCVCPU *cpu, uin= t32_t ext_offset, return; } =20 + if (cpu_cfg_ext_is_user_set(ext_offset)) { + return; + } + if (value && env->priv_ver !=3D PRIV_VERSION_LATEST) { /* Do not enable it if priv_ver is older than min_version */ min_version =3D cpu_cfg_ext_get_min_version(ext_offset); @@ -1847,6 +1857,12 @@ static RISCVCPUMisaExtConfig misa_ext_cfgs[] =3D { MISA_CFG(RVG, false), }; =20 +/* + * We do not support user choice tracking for MISA + * extensions yet because, so far, we do not silently + * change MISA bits during realize() (RVG enables MISA + * bits but the user is warned about it). + */ static void riscv_cpu_add_misa_properties(Object *cpu_obj) { int i; --=20 2.41.0 From nobody Thu Nov 28 07:57:12 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=1694153667; cv=none; d=zohomail.com; s=zohoarc; b=ZAxDbXmrLibwrwfOeGzOl5/oGuGzPFAWt7U9Vx2vRCEbTdsRKs7XF02ZyZremC6/6zdDwFsGEpyynil4nPgI6qHl37bMtxjsv2OeQUUXyp6Q5BG3YPRjf5UFWVG/ZTaZouMIW/PowY5h63dLmIdbh+02v/03hgHOy2NgR9w8wyo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1694153667; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3GMmaRv5643/zMFtvt7wVvyPYUKUz8B7XAztTFlqi0U=; b=a94J2FY8zFKI0kR/p0dlyd0JsHiNYpK+LaxhcaURPBXJjLEt3IAmwFIwOE3AkKzTcgttk2IBySVABzSnn9Agisv4vUM4JDfDdpGq7UjxbspNFMX80Z7qmjGMToiHlvGyPKUGqWBeOpWewuaA5fjOLbhfUv5d5y2mcBS+M1IQnmw= 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 1694153667485807.7327883827217; Thu, 7 Sep 2023 23:14:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeUfx-0007Oi-1L; Fri, 08 Sep 2023 02:09:05 -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 1qeUfv-0007Je-UK for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:09:03 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeUft-0008HB-8F for qemu-devel@nongnu.org; Fri, 08 Sep 2023 02:09:03 -0400 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-573d52030fbso1273163a12.0 for ; Thu, 07 Sep 2023 23:09:00 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id q1-20020a170902dac100b001c3267ae31bsm715231plx.301.2023.09.07.23.08.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 23:08:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694153339; x=1694758139; 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=3GMmaRv5643/zMFtvt7wVvyPYUKUz8B7XAztTFlqi0U=; b=dXSHlGzmBELyWliq9uguILASctIHYlbsyv+E0eigvyMzWrnh6YRtK5LObAZay5D2Jo 1Lut0D9TIMpf36W9u0ccKcnbU3O/2kIWCVncJ+tzo282Jhu8J7y8Na68hlwzZvMNOH3B 2vyGgoL4Eqny9k/PVngld6nKCOYKAdFFv2oSw/QjeZxxsXKwf6bYx3b+vWKp26E495gs rZ1Nn2VWm4MLSCTFTnK1XrecR3fbdiS+vLQ+E5J/FLTLTND99aDf0H987rM2w3wUUrwq vo6VPJZPddnArq2q3oC4Z8F07TCAozx9RcP0tYLyS66wumaqR4TGiWLXX4etxcY/jhSG vayA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694153339; x=1694758139; 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=3GMmaRv5643/zMFtvt7wVvyPYUKUz8B7XAztTFlqi0U=; b=U4tJ5uwFN4ldx+aBi5/WkcA8ohF3OGmkx1pUwA2xWCl19c9RQVTiivtU+9TfHYUyy7 oXOxn4/cr+slgT1Z3a09NxktqW9xgvv0e18kvuaXGug1ERzcSx+sbPi0NX/jxgYDdjob 2kRTMtW4hauwpRZUw4Um6xyHsLIBSjY6aGL9HzGsrcOjFq28LKow6fsDdnpvGzDH2rbP OJaJRItJItU/Rm9eQFLFy54XtuOQ44K/O7QFt6WOHYs8DqpACjpgl36JF/qHZHw6QWmb F5PuDxG9Ja3WhZWPUEQUNYJY+cwpZCEJz1FvbbpiP74d9QQoYpksqPgs15ZMYjZ41V3m qqsQ== X-Gm-Message-State: AOJu0YwvexGPBFoKL+ClYl6xgZRUihIVsNxtERCN5TxDv5233T31tMJE uSqz7CQOk/olGsl9nyHrLjQVhhQX06UVzwO7 X-Google-Smtp-Source: AGHT+IGjWnUmLVaUdEr5a99APJlLvHWnEoyFx19U+xM6T89TTVyhBs8NDl1meV3E3kTL4vRuutBgIQ== X-Received: by 2002:a05:6a20:3d92:b0:13e:9dba:ea52 with SMTP id s18-20020a056a203d9200b0013e9dbaea52mr2223908pzi.13.1694153339539; Thu, 07 Sep 2023 23:08:59 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Daniel Henrique Barboza , Alistair Francis , Andrew Jones Subject: [PULL 65/65] target/riscv/cpu.c: consider user option with RVG Date: Fri, 8 Sep 2023 16:04:31 +1000 Message-ID: <20230908060431.1903919-66-alistair.francis@wdc.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230908060431.1903919-1-alistair.francis@wdc.com> References: <20230908060431.1903919-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::536; envelope-from=alistair23@gmail.com; helo=mail-pg1-x536.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: 1694153668502100006 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza Enabling RVG will enable a set of extensions that we're not checking if the user was okay enabling or not. And in this case we want to error out, instead of ignoring, otherwise we will be inconsistent enabling RVG without all its extensions. After this patch, disabling ifencei or icsr while enabling RVG will result in error: $ ./build/qemu-system-riscv64 -M virt -cpu rv64,g=3Dtrue,Zifencei=3Dfalse -= -nographic qemu-system-riscv64: RVG requires Zifencei but user set Zifencei to false Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones Message-ID: <20230901194627.1214811-21-dbarboza@ventanamicro.com> Signed-off-by: Alistair Francis --- target/riscv/cpu.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 78382cb5f2..be1c028095 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1153,9 +1153,23 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu= , Error **errp) riscv_has_ext(env, RVA) && riscv_has_ext(env, RVF) && riscv_has_ext(env, RVD) && cpu->cfg.ext_icsr && cpu->cfg.ext_ifencei)) { + + if (cpu_cfg_ext_is_user_set(CPU_CFG_OFFSET(ext_icsr)) && + !cpu->cfg.ext_icsr) { + error_setg(errp, "RVG requires Zicsr but user set Zicsr to fal= se"); + return; + } + + if (cpu_cfg_ext_is_user_set(CPU_CFG_OFFSET(ext_ifencei)) && + !cpu->cfg.ext_ifencei) { + error_setg(errp, "RVG requires Zifencei but user set " + "Zifencei to false"); + return; + } + warn_report("Setting G will also set IMAFD_Zicsr_Zifencei"); - cpu->cfg.ext_icsr =3D true; - cpu->cfg.ext_ifencei =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_icsr), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_ifencei), true); =20 env->misa_ext |=3D RVI | RVM | RVA | RVF | RVD; env->misa_ext_mask |=3D RVI | RVM | RVA | RVF | RVD; --=20 2.41.0