Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp942430lqj; Mon, 3 Jun 2024 05:56:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW0dcN38Z021rJmCfRKFNnbNDZlTy6vcRNETx3J7L6d00rrpHuQatL3Ee8RTewk8vbCBPqYNzEsyTMbfjIXcXlh8G5Phgg9CyQnsFSMlw== X-Google-Smtp-Source: AGHT+IGzA1IXHZ6zw1/6lcwQMJWg1FsWiOQc1vl4/QHJVzrqQ376fqwx1bn6sH4FTuiuf6ueAnZf X-Received: by 2002:a17:902:d507:b0:1f4:7713:8f6 with SMTP id d9443c01a7336-1f6370a0cd6mr117894115ad.52.1717419414656; Mon, 03 Jun 2024 05:56:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717419414; cv=pass; d=google.com; s=arc-20160816; b=Y/TBhMItCjTNd+hIXI+ykZIRNZlRu/dppKaQqQLIzMlzsKKPq848fiKkM2NyWPf+Tv DNtLc9JdaaB8rT8weEbmrnOaja5nrRvBJQDHVQffTfF8jMKPUjQRPH8IFvVjz+aRpO50 RgVu9YjQmFwlQ2QXIAohSv4S8h8Ysaps5lRMok/eYQpenNrq0oMKrZWJHshPc03hDKjW aACub4DB/QFhiqhXTQsur5weZeUYf07oXCIQtE76yVa3hZ+KQFOtN7KT5JaBBoEBp6hl P1rixFY1GK4Cd4nhdSQ8ew233ortmiIQzLYZNnES6OWxggQpvokiSr65TFKXCTLY6D5H SDtA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=jznY1UA7/SXmEB87TeYXPvswNX7BAys1PkdQILLo1MY=; fh=nlxnPlHQ4Dn4SvWfiLzA4q+sq5jhS9fRhBz/0z/yvJ8=; b=Hd3j9ntOhFr1HycwVFXJ9xBDFGTczU7wnNdl2MTx5sgwN5GIzsNVGj8y8WZAlwOgPF oD2SmuV4qiUlB7d8tmCRt1CsOU6y7If1Uci1o/1BxCWCnzwAvmOnbdPQ2kBxn3cDGVfV 7/q91vJ9P8I1hRk58a3jpp8XpKU1oFbmFy6CejoZCQlSBlXLG/Zcl2IjWUs1D8bob3zU 9PBw892qcOtXazKCKom7pt+MQbGGSWndLPw7iZF6MNRy6FkVco4LYfZwJpft90nLXWTD ELc6KJ5kh9g2DO7N6OZvCiFjYtVzSYVFGfz5GaiLq8HFlWazGcKaKr3GYoTKKobb/p70 +Uvw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@brainfault-org.20230601.gappssmtp.com header.s=20230601 header.b=VaId9LVd; arc=pass (i=1 dkim=pass dkdomain=brainfault-org.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-199059-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199059-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f632401a99si866215ad.494.2024.06.03.05.56.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 05:56:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199059-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@brainfault-org.20230601.gappssmtp.com header.s=20230601 header.b=VaId9LVd; arc=pass (i=1 dkim=pass dkdomain=brainfault-org.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-199059-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199059-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B5B70283949 for ; Mon, 3 Jun 2024 11:40:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C1E0B84D07; Mon, 3 Jun 2024 11:40:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=brainfault-org.20230601.gappssmtp.com header.i=@brainfault-org.20230601.gappssmtp.com header.b="VaId9LVd" Received: from mail-il1-f182.google.com (mail-il1-f182.google.com [209.85.166.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2FA7684A46 for ; Mon, 3 Jun 2024 11:40:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717414824; cv=none; b=vGTYKCMSI9xSTYrO4laSE//3PhV+VaSJM80cydlx7NxnMccEno6HmiupIu8rh/OfTNJ+e+R7WgFvVsNjvhEbhXa1dYE5aPlIn+b6BGhXIRdLKytsmI8x6ITUzOKGuxhK/RxmrQaunzbyjGShIjgy3FmuiHS5u3UJcsG2mlIDMgY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717414824; c=relaxed/simple; bh=RRaEqV7B8iSS7qa/pDOAH3MqYofRF4D4b2oFQnNTQJ0=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=DIp416/vIhSQSLxkCPjvo1RH/h4jcAAtfyTVh4jAqmKDj/dFTTRHFzdaGXw5dpP0k9e5EOWZd46KxvRbO+N2DG8my8qQChg3AMQ9EYQdA+XENaM/kNWm6B1V/fhxqOCTpcO+iOUd3ALYcaPcWEZGO4Met0aOyJGLa49B2Vk6Rpw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=brainfault.org; spf=none smtp.mailfrom=brainfault.org; dkim=pass (2048-bit key) header.d=brainfault-org.20230601.gappssmtp.com header.i=@brainfault-org.20230601.gappssmtp.com header.b=VaId9LVd; arc=none smtp.client-ip=209.85.166.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=brainfault.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=brainfault.org Received: by mail-il1-f182.google.com with SMTP id e9e14a558f8ab-371cc143f6aso19925435ab.3 for ; Mon, 03 Jun 2024 04:40:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20230601.gappssmtp.com; s=20230601; t=1717414822; x=1718019622; 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=jznY1UA7/SXmEB87TeYXPvswNX7BAys1PkdQILLo1MY=; b=VaId9LVdcP8LsNBrkeurRiOKNXEeqoKTLyB33jLyIdn7O6HtYPBK04OiLmDKAy8Lvl 6XK1tuQtJ5WlNjFpJJ1Xv7+PWr+J1vN5IWD6wp3oOhvx0+jQKCyLkelGK/r9yA09NkRG NqOdZ0QaB+F3JaJmlsxspw/4SDd5kmNb/TMCk344ElII/IND2ynqo8KyTfSZDrhv719B OuSiUqmbgCYkNtH0JHvMMupYxEoO2IesBrecObvfRp2OmtiXPQDcIw8K/asHrpcafQ8h 5a0jtAWJ1xt8XIemoN+ldxTsCVBeIK7Cy9touYQwr717IUjBq0E0jBdXMg4VDJxNwQHC usVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717414822; x=1718019622; 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=jznY1UA7/SXmEB87TeYXPvswNX7BAys1PkdQILLo1MY=; b=eAJZ2IHCd4XUYRwTeAKhnOKpOfWH91h3b8PtcR0GUX0bpYKH5Rw+QXtdB3Y4Hwlie4 HTo1aP+Gs9us437Ja0unqIi32zdYuZ6kkNTGbjOtADGiuqjZBjW9Rl20wNcEH5yn4OrZ it3wDnKncoBL0Pexqa9AT7XYxdk8us1MPnQ41w8YcGZfpPRX0dEs5LwxQyZHaOdPeVtA TUVQI4ucrBY6oiD1Ntv7IJDO6LuY1QokxqmjvkEkM9lAJB4xv+LxVujWk03dg+G4anYk sHvOyfzMDS6Uj7hvD/sjyhYiu3bEmeI2F8K98sltpoRJAanNNzy7YvXpiNREk5P/i18i xmVA== X-Forwarded-Encrypted: i=1; AJvYcCWFbpmLDuOT2Kn7MHNZDTOx+aZnHYRggF53U/rPMmRGYMfYDXzRGzt/q4U9jkHn6tqxDMiG9eg2nvGqF5mnqBgc1mzx5OhDPt52t86g X-Gm-Message-State: AOJu0YydllYtVkhvwE0WMJRgoRiex71P7QgSPO2QC8Vu1lTQJhgUPd9M 7aa5srA7RjXq9FgBbx7hcNYJKMPky6V7+1wahZR7MpWtfxUD7JIgxk9r8GWTtXM4MvfzVSlLMz/ XUt6UHczETo0TFS7gT5qlN2xZIXUKaunFNrI9qrH++oCc5AOU X-Received: by 2002:a05:6e02:216a:b0:374:9995:b369 with SMTP id e9e14a558f8ab-3749995b506mr46562275ab.4.1717414822141; Mon, 03 Jun 2024 04:40:22 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240524103307.2684-1-yongxuan.wang@sifive.com> <20240524103307.2684-2-yongxuan.wang@sifive.com> <20240527-41b376a2bfedb3b9cf7e9c7b@orel> <20240530-3e5538b8e4dea932e2d3edc4@orel> <3b76c46f-c502-4245-ae58-be3bd3f8a41f@ghiti.fr> <20240530-de1fde9735e6648dc34654f3@orel> In-Reply-To: From: Anup Patel Date: Mon, 3 Jun 2024 17:10:10 +0530 Message-ID: Subject: Re: [RFC PATCH v4 1/5] RISC-V: Detect and Enable Svadu Extension Support To: Alexandre Ghiti Cc: Andrew Jones , Yong-Xuan Wang , linux-riscv@lists.infradead.org, kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, greentime.hu@sifive.com, vincent.chen@sifive.com, cleger@rivosinc.com, Jinyu Tang , Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley , Mayuresh Chitale , Samuel Holland , Samuel Ortiz , Evan Green , Xiao Wang , Alexandre Ghiti , Andrew Morton , Kemeng Shi , "Mike Rapoport (IBM)" , Jisheng Zhang , "Matthew Wilcox (Oracle)" , Charlie Jenkins , Leonardo Bras , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Jun 3, 2024 at 4:59=E2=80=AFPM Alexandre Ghiti wrot= e: > > On 30/05/2024 11:24, Andrew Jones wrote: > > On Thu, May 30, 2024 at 11:01:20AM GMT, Alexandre Ghiti wrote: > >> Hi Andrew, > >> > >> On 30/05/2024 10:47, Andrew Jones wrote: > >>> On Thu, May 30, 2024 at 10:19:12AM GMT, Alexandre Ghiti wrote: > >>>> Hi Yong-Xuan, > >>>> > >>>> On 27/05/2024 18:25, Andrew Jones wrote: > >>>>> On Fri, May 24, 2024 at 06:33:01PM GMT, Yong-Xuan Wang wrote: > >>>>>> Svadu is a RISC-V extension for hardware updating of PTE A/D bits. > >>>>>> > >>>>>> In this patch we detect Svadu extension support from DTB and enabl= e it > >>>>>> with SBI FWFT extension. Also we add arch_has_hw_pte_young() to en= able > >>>>>> optimization in MGLRU and __wp_page_copy_user() if Svadu extension= is > >>>>>> available. > >>>> So we talked about this yesterday during the linux-riscv patchwork m= eeting. > >>>> We came to the conclusion that we should not wait for the SBI FWFT e= xtension > >>>> to enable Svadu but instead, it should be enabled by default by open= SBI if > >>>> the extension is present in the device tree. This is because we did = not find > >>>> any backward compatibility issues, meaning that enabling Svadu shoul= d not > >>>> break any S-mode software. > >>> Unfortunately I joined yesterday's patchwork call late and missed thi= s > >>> discussion. I'm still not sure how we avoid concerns with S-mode soft= ware > >>> expecting exceptions by purposely not setting A/D bits, but then not > >>> getting those exceptions. > >> > >> Most other architectures implement hardware A/D updates, so I don't se= e > >> what's specific in riscv. In addition, if an OS really needs the excep= tions, > >> it can always play with the page table permissions to achieve such > >> behaviour. > > Hmm, yeah we're probably pretty safe since sorting this out is just one= of > > many things an OS will have to learn to manage when getting ported. Als= o, > > handling both svade and svadu at boot is trivial since the OS simply ne= eds > > to set the A/D bits when creating the PTEs or have exception handlers > > which do nothing but set the bits ready just in case. > > > >> > >>>> This is what you did in your previous versions of > >>>> this patchset so the changes should be easy. This behaviour must be = added to > >>>> the dtbinding description of the Svadu extension. > >>>> > >>>> Another thing that we discussed yesterday. There exist 2 schemes to = manage > >>>> the A/D bits updates, Svade and Svadu. If a platform supports both > >>>> extensions and both are present in the device tree, it is M-mode fir= mware's > >>>> responsibility to provide a "sane" device tree to the S-mode softwar= e, > >>>> meaning the device tree can not contain both extensions. And because= on such > >>>> platforms, Svadu is more performant than Svade, Svadu should be enab= led by > >>>> the M-mode firmware and only Svadu should be present in the device t= ree. > >>> I'm not sure firmware will be able to choose svadu when it's availabl= e. > >>> For example, platforms which want to conform to the upcoming "Server > >>> Platform" specification must also conform to the RVA23 profile, which > >>> mandates Svade and lists Svadu as an optional extension. This implies= to > >>> me that S-mode should be boot with both svade and svadu in the DT and= with > >>> svade being the active one. Then, S-mode can choose to request switch= ing > >>> to svadu with FWFT. > >> > >> The problem is that FWFT is not there and won't be there for ~1y (acco= rding > >> to Anup). So in the meantime, we prevent all uarchs that support Svadu= to > >> take advantage of this. > > I think we should have documented behaviors for all four possibilities > > > > 1. Neither svade nor svadu in DT -- current behavior > > 2. Only svade in DT -- current behavior > > 3. Only svadu in DT -- expect hardware A/D updating > > 4. Both svade and svadu in DT -- current behavior, but, if we have FW= FT, > > then use it to switch to svadu. If we don't have FWFT, then, oh we= ll... > > > > Platforms/firmwares that aren't concerned with the profiles can choose = (3) > > and Linux is fine. Those that do want to conform to the profile will > > choose (4) but Linux won't get the benefit of svadu until it also gets > > FWFT. > > > I think this solution pleases everyone so I'd say we should go for it, > thanks Andrew! Yes, this looks good to me as well. The key aspect is documenting the behaviour of these four possibilities. Regards, Anup > > @Yong-Xuan do you think you can prepare another spin with Andrew's > proposal implemented? > > Thanks, > > Alex > > > > > > IOW, I think your proposal is fine except for wanting to document in th= e > > DT bindings that only svade or svadu may be provided, since I think we'= ll > > want both to be allowed eventually. > > > > Thanks, > > drew > > > > _______________________________________________ > > linux-riscv mailing list > > linux-riscv@lists.infradead.org > > http://lists.infradead.org/mailman/listinfo/linux-riscv