Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1619994rdb; Mon, 2 Oct 2023 15:54:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHWx8HNV5rJ586V9rqgaF+lplxNjdEwwHiJp9atU4DL0k6AgKkNaRP/LQziXbotVeXpDsHe X-Received: by 2002:a17:903:1c8:b0:1c6:2780:3ad1 with SMTP id e8-20020a17090301c800b001c627803ad1mr15305210plh.57.1696287296469; Mon, 02 Oct 2023 15:54:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696287296; cv=none; d=google.com; s=arc-20160816; b=TYNL3vNdHAakISgt3ncf1eU0f3/SVtuPqIljXZIewsdm1qaKnGAHlTgBLxkYCBV8p2 YdQTmFrORzPss8HIV0uD/dYnz/17xfW4jgmtIBfncuBJDPD2xIPdBWpEl17a0GT5O4+r uLtpKtcyb5vvHSUfUH/KQplpChLzCEzbwhbVlNXh8WvW2rQspbYUp4ooHWRl1qCR+kPV sw62np4nCrBJsAjZI3faomdCq1yPmEoIzyDJPoCtFhN+rnFuVNMJUGHFQuBusJwOvB8w W2sgkq2CyzcjzjT55qMl8TVY0aC5/C+732Xm0l0t3RSZ9CssHBGH6av1UBwQt6lwxJe/ niuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=AurjURdP5ZlZL/smukAb81hKmuzUvXiFYPJa040s804=; fh=HpXMiQnsMD7rCCf+bR78dD5ocD+m5znDq0NwQNr2X/o=; b=OOyCKVyvKS7lbJkT3ZXj1YJ2ylEhFkXAHqyuaJEts9PJaj22kiAVdCwkdjljhSCAqh R2HYsL7ru5KPBkRKX77jpBCnW5guSlx3gIeHVpUeXbFaC2f0w1G1rJFX9VTudPIGi/8v 9q13sz1PPznajIl25mES4JN7sM/abMUo/X4NMpuqhNuVQ8Ef8EXm/ILfBRrLIJ2zS2dy yhZtkfg9uS+H8JI3XLoYwhWinmXLS0uq033AxNJXEssYh+r1DLUXLtL/DL5egC6z7jOY ttGqyOzaJNnaXys2eDBdu0b/D3KB+wwbqKzj9CKSAQqsDho/xhywiLpufLiwfrRcEizv No4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=YLQadow6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id q6-20020a17090311c600b001c589ba4a04si29435664plh.24.2023.10.02.15.54.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 15:54:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=YLQadow6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 830FD808D209; Mon, 2 Oct 2023 08:33:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238124AbjJBPdP (ORCPT + 99 others); Mon, 2 Oct 2023 11:33:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237779AbjJBPdN (ORCPT ); Mon, 2 Oct 2023 11:33:13 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8462DB3 for ; Mon, 2 Oct 2023 08:33:10 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2c1886777d9so80958411fa.0 for ; Mon, 02 Oct 2023 08:33:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696260789; x=1696865589; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=AurjURdP5ZlZL/smukAb81hKmuzUvXiFYPJa040s804=; b=YLQadow6VWpadkZcnF9aP4Ys+xkAty3Ouvkq+fTtvPIrHOIAkrde+V9LFX81Ipvwye a7VBijkKiTofRhtyBaIC19OeJ5sg/0aIqq4+wO3OJ37ooSO5pVeUZGd02MUgnIAPR7ol 2pollSyzXWpJccRtzgPE6s9VtxP9P2GrKzZ3ozHQ/tPcNfJODG6+pKZUOb0E4dHKwbFN joGjKftLsdjKQc1/VQm01pL2gAgC+NGYGdWS6qqie2xsIdD9eoOAaKrok1f1tOdUYfKv kS3SGTgyNluKONZ1vrRgK0I3n0UuugBBKPnqk+SzGHM2n+JsqFrzN+D5X72qvGWbW5ZG 1XMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696260789; x=1696865589; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AurjURdP5ZlZL/smukAb81hKmuzUvXiFYPJa040s804=; b=QUuvKOBSlVQnQm9YE+bsPflvOIk/1O0MYjkqB+IQNc1Z86Qa4oNuMqiQUC4kdjE1Je oOBh4HyUQzhipFfJ0I6MK38C5+cTK0I30QTKwWECSZjqgFoSqBSyaxJt1RGwDbviqY/4 /6I4h952kNvppfIBIg5oV28/INYiuxY39hIhn4DQwIYuYotJTNCHubCLRFGVSCmquzrx EynYJfJ1pVyQySpsHTQgNHPTihNsTfolVjQ7xs/znp1JuNdJBi7SXD3fmN7M7T40M5Ig 3eo/G0dz2ajckTAp0q8TE7CF20wrPiiHRF2ejld1x0JnfMqVeyWLRfc7I07XjTS39Wri VKEA== X-Gm-Message-State: AOJu0Yw08aCuXoX4pDS0/LMSaRduFu1RFsiaQVKFlPHYCqo+ITXZ8FPk GE4iMlNvkW7Q5UMui9y3gx2NCQOGIcFbfAh/lmY= X-Received: by 2002:a2e:8448:0:b0:2bc:f39b:d1a8 with SMTP id u8-20020a2e8448000000b002bcf39bd1a8mr9237063ljh.46.1696260788411; Mon, 02 Oct 2023 08:33:08 -0700 (PDT) MIME-Version: 1.0 References: <20230926150316.1129648-1-cleger@rivosinc.com> <20230930-patchy-curdle-ef5ee6e1a17c@spud> <8ce6cd97-6d63-4174-a290-40690c81e205@rivosinc.com> <20231002-spearman-doze-70cc026ac13e@spud> <693e6584-1e66-48c0-aa7c-61d9f88abd4c@rivosinc.com> In-Reply-To: <693e6584-1e66-48c0-aa7c-61d9f88abd4c@rivosinc.com> From: ron minnich Date: Mon, 2 Oct 2023 09:32:56 -0600 Message-ID: Subject: Re: [PATCH 0/7] Add support to handle misaligned accesses in S-mode To: =?UTF-8?B?Q2zDqW1lbnQgTMOpZ2Vy?= Cc: Conor Dooley , Paul Walmsley , Palmer Dabbelt , Albert Ou , Atish Patra , Andrew Jones , Evan Green , =?UTF-8?B?QmrDtnJuIFRvcGVs?= , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Maslowski Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 02 Oct 2023 08:33:22 -0700 (PDT) This was a very interesting read. One other thought crossed my mind, which is that a RISC-V implementation might make the alignment delegation hard-wired to always delegate to S mode. I.e, the bit might be WARL and always 1. For what I'm doing, this would actually be pretty convenient. Just want to make sure this code can accommodate that -- wdyt? We have found lots of value in our experiments with delegating alignment traps to Linux -- not least because they tend to locate problems in the kernel :-) -- we've found issues in module loading, early startup (there's a needed .align2 directive for sbi secondary startup, AFAICT) and the timing code for misaligned load/store handling. I don't know how you test this unaligned trap handling, but it might be worthwhile to work that out. You can test via oreboot and the visionfive2, save we have not figured out why SMP startup is going wrong, yet :-), so we're not as feature-complete as needed. But soon. Thanks! On Mon, Oct 2, 2023 at 5:19=E2=80=AFAM Cl=C3=A9ment L=C3=A9ger wrote: > > > > On 02/10/2023 12:49, Conor Dooley wrote: > > On Mon, Oct 02, 2023 at 09:40:04AM +0200, Cl=C3=A9ment L=C3=A9ger wrote= : > >> > >> > >> On 30/09/2023 11:23, Conor Dooley wrote: > >>> On Tue, Sep 26, 2023 at 05:03:09PM +0200, Cl=C3=A9ment L=C3=A9ger wro= te: > >>>> Since commit 61cadb9 ("Provide new description of misaligned load/st= ore > >>>> behavior compatible with privileged architecture.") in the RISC-V IS= A > >>>> manual, it is stated that misaligned load/store might not be support= ed. > >>>> However, the RISC-V kernel uABI describes that misaligned accesses a= re > >>>> supported. In order to support that, this series adds support for S-= mode > >>>> handling of misaligned accesses as well support for prctl(PR_UNALIGN= ). > >>>> > >>>> Handling misaligned access in kernel allows for a finer grain contro= l > >>>> of the misaligned accesses behavior, and thanks to the prctl call, c= an > >>>> allow disabling misaligned access emulation to generate SIGBUS. User > >>>> space can then optimize its software by removing such access based o= n > >>>> SIGBUS generation. > >>>> > >>>> Currently, this series is useful for people that uses a SBI that doe= s > >>>> not handled misaligned traps. In a near future, this series will mak= e > >>>> use a SBI extension [1] allowing to request delegation of the > >>>> misaligned load/store traps to the S-mode software. This extension h= as > >>>> been submitted for review to the riscv tech-prs group. An OpenSBI > >>>> implementation for this spec is available at [2]. > >>>> > >>>> This series can be tested using the spike simulator [3] and an openS= BI > >>>> version [4] which allows to always delegate misaligned load/store to > >>>> S-mode. > >>> > >>> Some patches in this series do not build for any configs, some are > >>> broken for clang builds and others are broken for nommu. Please try t= o> build test this more thoroughly before you submit the next version. > >> > >> Hi Conor, > >> > >> Thanks for the feedback, I'll check that. > >> > >>> > >>> Also, AIUI, this series should be marked RFC since the SBI extension > >>> this relies on has not been frozen. > >> > >> This series does not actually uses the SBI extension but provides a wa= y > >> to detect if misaligned accesses are not handled by hardware nor by th= e > >> SBI. It has been reported by Ron & Daniel they they have a minimal SBI > >> implementation that does not handle misaligned accesses and that they > >> would like to make use of the PR_SET_UNALIGN feature. This is what thi= s > >> series addresses (and thus does not depend on the mentioned SBI extens= ion). > > > > Ah, I must have misread then. Apologies. > > No worries, maybe I should actually remove this from the cover letter to > avoid any confusion ! > > Cl=C3=A9ment