From patchwork Fri Jul 26 08:49:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yong-Xuan Wang X-Patchwork-Id: 13742502 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 02C06C3DA7F for ; Fri, 26 Jul 2024 08:49:44 +0000 (UTC) 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: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=TjpojyU4mmppddBQ5PDjWSbW9UsBjp+aGiBmYrZcYkI=; b=Ds40x04XvfQlnM lARDAkjwi+6VcgftF7di6gVmmkpWv1XDgDzsdP5C9HXppCYXhaBPbLMWY5bEiUQmHqlcskjUC55f7 KC2e89oPc4QjLyMlK+hQYP18Z6XFXGxamZCb/mgjEIuMaZWTA4oreBnLn6a9bs2IZiQZe4xFx79ok p9scO317FDPfzUmXFop/ySXg5HFjmdL0vaZTklR0UQbVOKrD4aRVzUkzD/jqOzg1Nj69Fpy5oMvnL TFUuRaUIxgw2fqFyN28yaRe2Wd8gW3CYhRW6UNMMvlyP1zHo+GBaVeGz+Gu5vJ2tQKx+ZJf2cQV6i O/R5IZLg+6flqCuTsYcg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXGdw-00000003Mug-3BmL; Fri, 26 Jul 2024 08:49:40 +0000 Received: from mail-il1-x12b.google.com ([2607:f8b0:4864:20::12b]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXGdt-00000003Mtd-0QKz for linux-riscv@lists.infradead.org; Fri, 26 Jul 2024 08:49:39 +0000 Received: by mail-il1-x12b.google.com with SMTP id e9e14a558f8ab-39834949f27so6341795ab.2 for ; Fri, 26 Jul 2024 01:49:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1721983776; x=1722588576; 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=7XZtOcVU71qgefN2Ru/3ZszUxxOG8b1uowiT0jlNrFY=; b=CQcOhZxnkXS/9v9O+hxBgBxJQ8NkkILI3C2TFvbMv42cxR+55GcUv0FgW4DGdOoCxc HZqomPKUi9lUqlCAz436lmcuL2eVqpBv+gvEq8zdLcwZfoxB+om6OwMbqYKriDSouCyD w2r2NXHQHohD6YRnig1a6Wt2R3Nr03Ysz+QflDvE9ChiU3Rb25CTF2j6CmvYq03vbHhB 9Ke/hcuqV2HnhLewB8bfNFpA8GgKGp4wmnk1pkw6FGP9f2Mq4rEHlPwVRbIhbbmV3a6h Z50WsSi6M6kGyqh5JBktvQpeRlm7vD+ex4KKZNolSd3n1cmJSB6UQ0cL7gPk0JiJm+L7 AU8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721983776; x=1722588576; 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=7XZtOcVU71qgefN2Ru/3ZszUxxOG8b1uowiT0jlNrFY=; b=HpXXXOT3ofytTTAK/EGlACxjhL6284aO3x/L6TrUN3vT9AnRR0bylcb9D3qfBGRhzF h8GkL1SzMawsJsOG5rqYlEADDUHzABpqv97roxg3f+MIS4TAfPEAq3xgyUtzRaprjt0J t3sSaNyuHxnQsruIpWoxlWgzE8Ws+U2ZLz6rvXXqcsss/J85zgwBFIghcoda0RTJU8ZH eP/pz4xekWFFqwQDPaIh33JNYyMoaOj4Ug54MqyEGlzbvcvzQTFNGuhi0YF0KOBDQoB3 z3Zybrtj/lSW9e067eBq4YU9HDlWtgv8AQenzpmdfARqGTUnwOVqOjL6Cbnye0Xud8PL 9lVw== X-Forwarded-Encrypted: i=1; AJvYcCWVx7TOTALDqtWffc7oymGD4w0DZn2YXqRnCVISnBKgVemhDHxSYYk0aMrhQuVotSLINzHPVH1Kmq6EU9c2K6ba72tUip5ev9ofDUGL7jRr X-Gm-Message-State: AOJu0YwTaZH0Aekkp7jk41cYQzHe/zPHzEvENrELTlVR/HpeV+CnQEGM 1IOX05YQHWP9p2NM3rk0raDZupQjz8L0ErjDFeAGWLHijA/129DJOI6U6Fm6kmdt9jkGj+IKPyX dNnw= X-Google-Smtp-Source: AGHT+IGIIC3hug3f1RinXPtTRLJ3e0ZL1wTw+7Nz0b4GXlvTkp9mdYRpo/TwavDaXmzo1aFws3QMLA== X-Received: by 2002:a05:6e02:1aa1:b0:379:40e0:b0b8 with SMTP id e9e14a558f8ab-39a2185d921mr63531485ab.20.1721983775853; Fri, 26 Jul 2024 01:49:35 -0700 (PDT) Received: from hsinchu26.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7a9f816db18sm2049645a12.33.2024.07.26.01.49.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 01:49:35 -0700 (PDT) From: Yong-Xuan Wang To: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, kvm-riscv@lists.infradead.org, kvm@vger.kernel.org Cc: greentime.hu@sifive.com, vincent.chen@sifive.com, Yong-Xuan Wang , Paul Walmsley , Palmer Dabbelt , Albert Ou Subject: [PATCH v8 0/5] Add Svade and Svadu Extensions Support Date: Fri, 26 Jul 2024 16:49:25 +0800 Message-Id: <20240726084931.28924-1-yongxuan.wang@sifive.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240726_014937_350894_A22E4950 X-CRM114-Status: GOOD ( 14.66 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Svade and Svadu extensions represent two schemes for managing the PTE A/D bit. When the PTE A/D bits need to be set, Svade extension intdicates that a related page fault will be raised. In contrast, the Svadu extension supports hardware updating of PTE A/D bits. This series enables Svade and Svadu extensions for both host and guest OS. Regrading the mailing thread[1], we have 4 possible combinations of these extensions in the device tree, the default hardware behavior for these possibilities are: 1) Neither Svade nor Svadu present in DT => It is technically unknown whether the platform uses Svade or Svadu. Supervisor software should be prepared to handle either hardware updating of the PTE A/D bits or page faults when they need updated. 2) Only Svade present in DT => Supervisor must assume Svade to be always enabled. 3) Only Svadu present in DT => Supervisor must assume Svadu to be always enabled. 4) Both Svade and Svadu present in DT => Supervisor must assume Svadu turned-off at boot time. To use Svadu, supervisor must explicitly enable it using the SBI FWFT extension. The Svade extension is mandatory and the Svadu extension is optional in RVA23 profile. Platforms want to take the advantage of Svadu can choose 3. Those are aware of the profile can choose 4, and Linux won't get the benefit of svadu until the SBI FWFT extension is available. [1] https://lore.kernel.org/linux-kernel/20240527-e9845c06619bca5cd285098c@orel/T/#m29644eb88e241ec282df4ccd5199514e913b06ee Acked-by: Palmer Dabbelt --- v8: - fix typo in PATCH1 (Samuel) - use the new extension validating API in PATCH1 (Clément) - update the dtbinding in PATCH2 (Samuel, Conor) - add PATCH4 to fix compile error in get-reg-list test. v7: - fix alignment in PATCH1 - update the dtbinding in PATCH2 (Conor, Jessica) v6: - reflect the platform's behavior by riscv_isa_extension_available() and update the the arch_has_hw_pte_young() in PATCH1 (Conor, Andrew) - update the dtbinding in PATCH2 (Alexandre, Andrew, Anup, Conor) - update the henvcfg condition in PATCH3 (Andrew) - check if Svade is allowed to disabled based on arch_has_hw_pte_young() in PATCH3 v5: - remove all Acked-by and Reviewed-by (Conor, Andrew) - add Svade support - update the arch_has_hw_pte_young() in PATCH1 - update the dtbinding in PATCH2 (Alexandre, Andrew) - check the availibility of Svadu for Guest/VM based on arch_has_hw_pte_young() in PATCH3 v4: - fix 32bit kernel build error in PATCH1 (Conor) - update the status of Svadu extension to ratified in PATCH2 - add the PATCH4 to suporrt SBI_FWFT_PTE_AD_HW_UPDATING for guest OS - update the PATCH1 and PATCH3 to integrate with FWFT extension - rebase PATCH5 on the lastest get-reg-list test (Andrew) v3: - fix the control bit name to ADUE in PATCH1 and PATCH3 - update get-reg-list in PATCH4 v2: - add Co-developed-by: in PATCH1 - use riscv_has_extension_unlikely() to runtime patch the branch in PATCH1 - update dt-binding Yong-Xuan Wang (5): RISC-V: Add Svade and Svadu Extensions Support dt-bindings: riscv: Add Svade and Svadu Entries RISC-V: KVM: Add Svade and Svadu Extensions Support for Guest/VM KVM: riscv: selftests: Fix compile error KVM: riscv: selftests: Add Svade and Svadu Extension to get-reg-list test .../devicetree/bindings/riscv/extensions.yaml | 28 +++++++++++++++++++ arch/riscv/Kconfig | 1 + arch/riscv/include/asm/csr.h | 1 + arch/riscv/include/asm/hwcap.h | 2 ++ arch/riscv/include/asm/pgtable.h | 13 ++++++++- arch/riscv/include/uapi/asm/kvm.h | 2 ++ arch/riscv/kernel/cpufeature.c | 12 ++++++++ arch/riscv/kvm/vcpu.c | 4 +++ arch/riscv/kvm/vcpu_onereg.c | 15 ++++++++++ .../selftests/kvm/riscv/get-reg-list.c | 16 ++++++++--- 10 files changed, 89 insertions(+), 5 deletions(-)