From patchwork Sat Mar 2 11:25:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bo Gan X-Patchwork-Id: 1907121 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=M5SzRiHG; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=DTRrYEUu; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tn2hD1Lqsz1yX7 for ; Sat, 2 Mar 2024 22:25:48 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=sx3Hamqrc9K1Y1Qwp2aGBysO5EottCSG08e6ZGr05Is=; b=M5SzRiHGimmVeF XqQsIjPeLL15CrGBE9e7OIDnzcuvfRici2EhlqIbAba+q4kvWTSXw04sVCnA39QNKyFoJo3yADB6a 1pxA3TgFCwSA99CJUhvFY38GhWvdamyQ1Qks1TmskxSR/zCO+TrTpyYNZhgoSasoK0584vbRauFTL XES1OcxdxZF1ZdvlOOpZKo9eLTwKeVf8lq/pjAxLCI5ir03M/ssftMVfIfmOOIb00x5i+MTnEwN7r 67ecyw8myned+wJvpPuqSTcVjTJLK1qEmwVYvTWdMLVG1r6fphShRSNL/TL8dR53pBaqvomQgikrb oRHNpx1xoUyJHJtaQAkw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rgNUo-00000003PXj-0R9I; Sat, 02 Mar 2024 11:25:38 +0000 Received: from mail-ot1-x335.google.com ([2607:f8b0:4864:20::335]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rgNUk-00000003PWT-25pj for opensbi@lists.infradead.org; Sat, 02 Mar 2024 11:25:35 +0000 Received: by mail-ot1-x335.google.com with SMTP id 46e09a7af769-6dc8b280155so2281084a34.0 for ; Sat, 02 Mar 2024 03:25:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709378732; x=1709983532; darn=lists.infradead.org; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AyMijHgCoHdM81nYYq+5dYXQdQK/Pk/XNlW+dGurJ2E=; b=DTRrYEUukZQ0dHdGNv6IxIxcENK+wxQiBvFL6ICltllOHOxVJwHpLkZStE5UMfqE/u vuwR4drr2JzHbHtCT4/AFwiRMRg+G/mpUxqFdariZ0YLWmlECkk2COTVNzt6dqKCp+Ep SNvlR+pmCJ9tTIMij6tt1AATEonHoiNo5LHm3OAFCLuWWGA2M0Q85xXcYKeiKf2h813M 4jWoD9Vlh0SD8EuILtNC4v0ScwgwMOU96oU+b/h6uP7eiFa+ITSUCVRCSoTHO3rSc3sB KHSjkmrSZBpPx/baqA6pue2roxnKx3TdVDJpnFqksgyr5mDYWW3O+xB4wLj9VAj2bgoR UByg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709378732; x=1709983532; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AyMijHgCoHdM81nYYq+5dYXQdQK/Pk/XNlW+dGurJ2E=; b=Vd5OyaRZvoza3UKVFeoGH5+3QSAZHeLdGJpNa/MiLimHjY28g85VIDE25+NN6uH89H IVS9sRUHACSsW0rEKsnBmOi+JG2FdWP3Qc9ahrYT1E6oePLwNVwETLRhG9wObewclA+4 8Nehym9ZBT1rMMku4+yuSmMRAqmttPnDFu2SyfJ1/5WRNChuBbP0nIpl2H8cgAyzinnz WiAEnesMX06lu1YUJPJ1yvIzAB8QSlmYjOPiV19fJnkriXHPyPFny3N9y6TQUV1V/1kO YDEGEtWlW/lrdUhFn3A/nY6fd8VMpAJI4RtJWSYSfuG1TPQbWjVFgcSq46dr7arxfEjd tfyA== X-Gm-Message-State: AOJu0YxYVHtvUdxIItAIilvYZyvsy/jSS6MLdO/dsjtj8LaMs/zZHRTT E1dEq4vg4alH3nreFDJp114tQGkiHc2z1xt0g2Lx/6onYIVxomg4ySbw/o1N X-Google-Smtp-Source: AGHT+IGtMvzoS7+QUxWbE6/zKF19R4ynvwB92oSCjzuxDyTsWyrum+W9fpe+ekMtv5vDRgEguwsgVw== X-Received: by 2002:a05:6871:2894:b0:220:cac8:b78a with SMTP id bq20-20020a056871289400b00220cac8b78amr2922554oac.46.1709378732214; Sat, 02 Mar 2024 03:25:32 -0800 (PST) Received: from m91p.airy.home ([172.92.174.232]) by smtp.gmail.com with ESMTPSA id ih12-20020a0561022d0c00b0046ecdfd5a94sm21265vsb.14.2024.03.02.03.25.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Mar 2024 03:25:31 -0800 (PST) From: Bo Gan To: opensbi@lists.infradead.org Cc: wxjstz@126.com, anup@brainfault.org Subject: [PATCH v3 0/6] Allow platform to handle load/store faults Date: Sat, 2 Mar 2024 03:25:19 -0800 Message-Id: <1709378725-56656-1-git-send-email-ganboing@gmail.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240302_032534_562844_CB13B925 X-CRM114-Status: UNSURE ( 9.79 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Sometimes a platform wants to trap-n-emulate special devices or filter access to physical devices. This patch makes sbi_trap_handler to call platform_ops.emulate_load/store and ask platform to fixup t [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:335 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [ganboing(at)gmail.com] -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Sometimes a platform wants to trap-n-emulate special devices or filter access to physical devices. This patch makes sbi_trap_handler to call platform_ops.emulate_load/store and ask platform to fixup the fault. v3 changes: - Addressed comments from Anup by breaking down the patchset and new sbi_platform_emulate_load/store helper functions. - Reworked the return value of sbi_trap_ld/st_emulator to support (>0) successful emulation (==0) trap_redirect (<0) real failure. v2 changes: - Added const qualifier to *orig_trap on load/store fault handlers. That addressed Xiang W's comment. - Applied clang-format to changed lines. Bo Gan (6): lib: sbi: rename sbi_misaligned_ldst.c to sbi_trap_ldst.c include: sbi: rename sbi_misaligned_ldst.h to sbi_trap_ldst.h lib: sbi: change prototype of sbi_trap_redirect lib: sbi: abstract out insn decoding to unify mem fault handlers include: sbi: add emulate_load/store handler to platform ops lib: sbi: call platform load/store emulators include/sbi/sbi_misaligned_ldst.h | 23 --- include/sbi/sbi_platform.h | 11 ++ include/sbi/sbi_trap.h | 2 +- include/sbi/sbi_trap_ldst.h | 55 ++++++ lib/sbi/objects.mk | 2 +- lib/sbi/sbi_trap.c | 38 +++-- lib/sbi/{sbi_misaligned_ldst.c => sbi_trap_ldst.c} | 189 ++++++++++++++------- 7 files changed, 218 insertions(+), 102 deletions(-) delete mode 100644 include/sbi/sbi_misaligned_ldst.h create mode 100644 include/sbi/sbi_trap_ldst.h rename lib/sbi/{sbi_misaligned_ldst.c => sbi_trap_ldst.c} (60%)