From patchwork Mon Jul 1 14:54:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 1954738 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=BmKda9rI; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=IBqPEH04; 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 4WCTc82Yd7z1xpc for ; Tue, 2 Jul 2024 00:55:18 +1000 (AEST) 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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=NRch/83tCNBvm+TQLs4P8SnNNyX5JqbtgT3Jpvaty8s=; b=BmKda9rI7pu5P+ tMPy75bj/2x1G+8vkwEmQZ7/uqYKiPJ28clx07b8enAhSFf4WvRR4OMswGhMCUC5NBIcJqUsGnMhO iN0YoFRatcMhmTzZgtt3Z9QP1eTfIzgUayUhtI85svPV2XWhluRBRJlMUzNeOPKkuRbCg/CiCqhsZ smJWWotNIrgpihihojV8oVcynuQsMGZ9hDOFWwabeawM8tVvrxP4cKSnRN0zdUGFsCPr7SCUFJ239 FvnMvQF6iGvx6nXsLEIY3Ab8GcIXzVQA+6K1t+W9BWfR/kU8TAa3d21VjsE87wHwCZOGEL51IZdoe d6LD95BBRsJfIGhp5CTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOIQt-00000003o07-3oX1; Mon, 01 Jul 2024 14:55:07 +0000 Received: from mail-ot1-x334.google.com ([2607:f8b0:4864:20::334]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOIQq-00000003nzE-359m for opensbi@lists.infradead.org; Mon, 01 Jul 2024 14:55:05 +0000 Received: by mail-ot1-x334.google.com with SMTP id 46e09a7af769-6f855b2499cso1891996a34.1 for ; Mon, 01 Jul 2024 07:55:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1719845703; x=1720450503; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=6r7qHpn6kITCwqdluVYAnqIuU86JECSgiItXRjuShzY=; b=IBqPEH04ViPXWcbxjo1PsxiJElHRBCeo6hkyur2HV8UmsuCrVMrk2inWteGA9lYIQe iAaYyAxMHa/1lOgM6eBAbemIeC3Rt0IFM0Hu+uCcA3oAtMeL2I9jycVEhEwrSfeYBpDV GYtCFWUtP0rwWDJAvxNh2Z5VVQTeh8FB2Q3kzFd77IuFDS0V3uCmjKPoc6hGwadPH/zx 8HkANxYZ3+aq1Tuw61NU3ME5RlFVaJBJoPq5vPMFpFT5PgOYDXK6CAWCCoC6MvDGaIIP TljxGaUwIlXBO3iD3KbUUh4+b53zdd+b5xFERrMsKFjuIs5pRD65WDwbvSlZUortt9DI efww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719845703; x=1720450503; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6r7qHpn6kITCwqdluVYAnqIuU86JECSgiItXRjuShzY=; b=HVMpa3ylJMGrwF08VNTR96TSc5ulzQcQhdWaqn+eNe/tvFGULwDPK40bn+tRAccfHm ZeWS5fTdp/v4ROKsDH/VxfJnq8zHfn20+Rr7PNyae1yOwyshzYaatlqcXxSgDD65Mc0+ eNAOgS8juxDEYrV3HMfhZV0azu9oPb9ujPzYNvZbD4pg6Rqz68l0/ygK06ulOk93JNCL 2Gv187pYFhxaXeqOHuSqHsMWhA9WFy/TGlTRRMyErKQIcZ7L4sTRgEcyPvs7xMWHBmMq iquuXL9tTJfh0vXH0wRVeqFxZg9bgLI+RqHDABJQRUuEYbzEnFgqV6SBhuiccmVIoB7G KVbQ== X-Gm-Message-State: AOJu0YxyWzLn+gOS0gYsCPsf1bbEpKCZhkNSt7Yk0cCXY7XeOFgd2+Eb z8PVpWkVXaHtW/27Y2MGajmxRICpq2hMFYO1DYuqGZMe+yiMWlJ/L6gUgyfapQ8eg05M9sDWAFW 8bKN/owApXX/intlGzQgWgh8cd8BNlhe41DmfIsyHoTcgevcB0yMMFLyoyVNpGdFoP4nfQ0jSyR jGIPvqSjr/XYNVBQ5KLynybix3TzvNLVGYiegdngBKgLfyQbiv4P0= X-Google-Smtp-Source: AGHT+IHNxs0cZSITAcO904Z664x2lOlv4zUwcp2GWenk1P3G0vxsRTm6KdFr+5YUl8nxikaESL/9AA== X-Received: by 2002:a05:6830:1d4b:b0:700:d023:6b31 with SMTP id 46e09a7af769-702075de2c2mr6840732a34.18.1719845703476; Mon, 01 Jul 2024 07:55:03 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-72c64613e88sm4416368a12.0.2024.07.01.07.55.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jul 2024 07:55:03 -0700 (PDT) From: Samuel Holland To: opensbi@lists.infradead.org Subject: [PATCH] lib: sbi_emulate_csr: Do not log illegal CSR accesses Date: Mon, 1 Jul 2024 07:54:58 -0700 Message-ID: <20240701145501.761348-1-samuel.holland@sifive.com> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240701_075504_825254_4C5681B6 X-CRM114-Status: GOOD ( 10.33 ) 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: Illegal CSR accesses from lower privilege modes are delegated to S-mode and do not necessarily indicate a bug. Supervisor software may want to emulate some CSRs, or may intentionally disable access to [...] 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:334 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_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Illegal CSR accesses from lower privilege modes are delegated to S-mode and do not necessarily indicate a bug. Supervisor software may want to emulate some CSRs, or may intentionally disable access to certain existing CSRs, and thus will expect traps when those CSRs are accessed. For example, Linux disables sstatus.VS by default in order to detect when userspace first accesses vector register state; this includes the CSRs defined by the V extesion. As a result, if the first vector instruction in a process is a CSR access, OpenSBI will log the illegal instruction exception, even though there is no unexpected or erroneous behavior occurring. Since the illegal instruction exception is delegated to S-mode, S-mode software should be responsible for reporting the exception, not OpenSBI. Signed-off-by: Samuel Holland Reviewed-by: Anup Patel --- lib/sbi/sbi_emulate_csr.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/lib/sbi/sbi_emulate_csr.c b/lib/sbi/sbi_emulate_csr.c index 5f3b111d..869c81f4 100644 --- a/lib/sbi/sbi_emulate_csr.c +++ b/lib/sbi/sbi_emulate_csr.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -151,10 +150,6 @@ int sbi_emulate_csr_read(int csr_num, struct sbi_trap_regs *regs, break; } - if (ret) - sbi_dprintf("%s: hartid%d: invalid csr_num=0x%x\n", - __func__, current_hartid(), csr_num); - return ret; } @@ -189,9 +184,5 @@ int sbi_emulate_csr_write(int csr_num, struct sbi_trap_regs *regs, break; } - if (ret) - sbi_dprintf("%s: hartid%d: invalid csr_num=0x%x\n", - __func__, current_hartid(), csr_num); - return ret; }