From patchwork Wed Dec 11 21:19:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Konrad X-Patchwork-Id: 13904215 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 04352E77183 for ; Wed, 11 Dec 2024 21:21:33 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tLU8G-0006pQ-1d; Wed, 11 Dec 2024 16:20:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tLU8E-0006p3-Cf; Wed, 11 Dec 2024 16:20:30 -0500 Received: from mail-bn8nam04on2060c.outbound.protection.outlook.com ([2a01:111:f403:2408::60c] helo=NAM04-BN8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tLU8B-0003nJ-MK; Wed, 11 Dec 2024 16:20:30 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=T4M55+E6HVpBI3gSifWgwdFwiVDgLOItSvDvxfapoIQz2tDGuvqcd3bpXI977Z/MTZecm4VgGWjpO/xQ68M3YGljpDTWOvCAUJDbe3MP6qIX+ujJVXc4vm1zYD3cQfin2rJOCWtaiQFoO/Qp130kMxulWKm9Wt156XTkV35NQJ0IV1e17jZHWEaShIpQgrqJxm4+HpKOYMMwe6/gNz6tqFadEAYMV1I8EEM2VTlV82SjOArcN5TsOvCpYCInNFCBpU2HTHgD6mcu15dY/ixoKNsRd6ei4SImWFp06ip3xMQx+S7eiKjD6ujBlrthGIQeqFxbD7V9A1mFhKNz1588Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IBq1fkGpqYwoSlGE6gmA03v/TYvex1GA5CtsDM4punA=; b=yBkszLo1Kdj+4+PLfZ8g8ZSeo/5vvkRAU/FWLdCKcZmRmPKSzt72Zpyq+cmAj60E9swF+wLFYGgj4R/I6gGHcN2VuZ7fqJ7jUKd0W6Ds2q1bC3xuK5SyChUdDx6mI3bjN1orFMORISvsO3DhS75lWu75R4PVzBrGgaiQj1IJCxwTnIjtBmR4AIOXKBqROMYZEpUPEtOWBKbLetPswPBA8b3xmLriyLJmGCXl6HdRy4CAWyxnlq70ymbfwScg+b7ZHXatstUyKWjBVBVxQ3s9jiErgfs8iNsPOlioEjDa5VI5tmxX22PhXVc3gCK64JYnFu41nW9pdFM4eeBWjyl48A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IBq1fkGpqYwoSlGE6gmA03v/TYvex1GA5CtsDM4punA=; b=EOWcCvKW6LRYl//pPBVUjY9rsRbEiKUh5Zfm8FtY+tiMss0f7aErx9SFTPcbNbKGE+rdvRIQCj+j9x+8/ZrstHWq9d6sKRBool0hsOJRnZHXwk8eiD/6rK5WnZPvOTobJIC1qWPwa2fnxhn1O/Ys+dPG8ca0KhVyBtJugCMVYVc= Received: from MN0PR04CA0022.namprd04.prod.outlook.com (2603:10b6:208:52d::21) by SN7PR12MB7787.namprd12.prod.outlook.com (2603:10b6:806:347::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Wed, 11 Dec 2024 21:20:14 +0000 Received: from BN3PEPF0000B06D.namprd21.prod.outlook.com (2603:10b6:208:52d:cafe::6c) by MN0PR04CA0022.outlook.office365.com (2603:10b6:208:52d::21) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.18 via Frontend Transport; Wed, 11 Dec 2024 21:20:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BN3PEPF0000B06D.mail.protection.outlook.com (10.167.243.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8272.0 via Frontend Transport; Wed, 11 Dec 2024 21:20:14 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 11 Dec 2024 15:20:13 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 11 Dec 2024 15:20:13 -0600 Received: from xfr-fkonrad-l1.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Wed, 11 Dec 2024 15:20:11 -0600 From: Frederic Konrad To: CC: , , , , , , , , , Frederic Konrad Subject: [PATCH 0/3] riscv misaligned accesses Date: Wed, 11 Dec 2024 22:19:30 +0100 Message-ID: <20241211211933.198792-1-fkonrad@amd.com> X-Mailer: git-send-email 2.43.5 MIME-Version: 1.0 Received-SPF: None (SATLEXMB05.amd.com: fkonrad@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B06D:EE_|SN7PR12MB7787:EE_ X-MS-Office365-Filtering-Correlation-Id: 4325f022-167d-43cb-2d53-08dd1a299a53 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: XovrBPwhTkuYCQm+Gxpqf3OtbRLc5iA5NaxG8zMSgccSfukFDSNTtr5yGdbscG9gHGyBT4Go0dIx8NBk6DwTqvWp5lrum/lbcmdFWXCFSokCR1i56GCyIpnLMNZ09XnHatlEDOrYcsBPTYyrGjDsdXHcQntketP/WXHjyDzF6GM9EdFTwFxfnwwk3JRgbQodIIFNyKPcGFLTlba/fM4DLY8HDqOpYX4he4kalfrNhg1tKgPIb1khG2oYcw3hA1+RvRs6uqxUYntl/jojEBpZeZb8GgBuoO5v01ubUs68DGuKusXCYKnyXCj/zAvihkCj12S6BeG5vFSLCjlMZdnt660nL6zsuX2PfYPExsm69bUxrLvm6jupgEBwSRH6F2Q8V6wk/WVrD9C8sxcA+XxHzkpQ/yhAMxiDT/MpzEGRRy9Is8svas6SIvlFfAdrOEHi5pWqgVnFNo3wk/sh3zotzBjO/tmiYYJ7BS8TmZLJXp4wgUiArO1hh278zid3JD4rE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E; SFS:(13230040)(376014)(1800799024)(82310400026)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2024 21:20:14.0977 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4325f022-167d-43cb-2d53-08dd1a299a53 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN3PEPF0000B06D.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7787 Received-SPF: permerror client-ip=2a01:111:f403:2408::60c; envelope-from=Frederic.Konrad@amd.com; helo=NAM04-BN8-obe.outbound.protection.outlook.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.472, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Hi, I fell into some strangeness while using RISCV: * firstly the rvi stores / loads don't seem to generate a trap when doing a misaligned access, which is something we would like to happen. According to the documentation an EEI may or may no guarantee misaligned loads and stores are handled invisibly. Thus PATCH 1 adds an option for enabling those traps, and PATCH 2 raise it when enabled and Zama16B (which implies atomicity for misaligned access within 16bytes boundary) is disabled. * secondly about the conditional store: the documentation states that the Zalrsc extension requires that the address held in rs1 is naturally aligned to the size of the operand. The current implementation doesn't do that check if the store doesn't happen, so the third PATCH fixes that behavior so that a misaligned trap will happen if the address is not naturally aligned even if the store shouldn't happen. Best Regards, Fred Frederic Konrad (3): target/riscv: add a trap-misaligned-access property target/riscv: generate misaligned access trap for rvi insn target/riscv: fix the trap generation for conditional store target/riscv/cpu.c | 5 +++++ target/riscv/cpu_cfg.h | 1 + target/riscv/insn_trans/trans_rva.c.inc | 19 +++++++++++++++++++ target/riscv/insn_trans/trans_rvi.c.inc | 7 +++++++ 4 files changed, 32 insertions(+)