Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4507628rdb; Fri, 15 Sep 2023 04:37:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEggh9sO9UFjSOJ9Zi50H4hbldms21BbDEAiJySyfM381oWlRTkHIVZeTfuDjAvwZfGlcIj X-Received: by 2002:a05:6358:e483:b0:13c:ec81:c276 with SMTP id by3-20020a056358e48300b0013cec81c276mr1774557rwb.5.1694777861696; Fri, 15 Sep 2023 04:37:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694777861; cv=none; d=google.com; s=arc-20160816; b=zCVGq3P8Tq4AAhWTrkx1zBqQQsE3FxnlZdvZc4tlCvUt3JTyuMpTJAOW+lvjvIEBPI emNcKqdQHD9YP5hkAjZbV83sbtdsuEHNhltbxa93tKRTpzpKZ45XgbPqvJ+/bgJObABZ C6wzJk1wYgebn1ZGHJtCytEhy3AowRnTN07Ze5pWhDP7xp2Ya+IliwHAv/RkN01t3BJZ ClGxvinkdHUlTgt2eamRIphrgR7VslgjhKzANE4WSnHV8w4km72v3ts3mngWkbBufymc ypqmO8SccWwAqT8FKvez9bCWfziWSSCKn+EACLUz4YNQBZgL3vTKcL0gqMLFnydTdkW+ b9tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=/d7/3Obm53ZQCMrVF3c99mLRUxxcGODrgFkkmXmmWh0=; fh=pglOtI1A4vJBnnwcOyMDm0nuF5QQq5sdJWQLYQGDa+Q=; b=bId4mv0tUwizq2ygyEL8x1NyQKodFJD+vKe/6qNQfvyQoJnwvcfJwTACNVv3s/lbkx 8IaW9LwtZISmqOAS4KqgI22jixMbMgl6PuJIysTcxdevtHUmwM3UARHB9ILN9BJyYn36 Rst6BqS0Zrm7+GozQCPUPRyqx4cxbD413/f3RC5KL6S4aNmr9RbBOXuVZAk7iYfOZKOD cmy2Y6PwpWfJ3++KdDSmYMqQ/zoR7mN54O+Vpou988XjxNtVMuL05pMQ0G7hcyrmi27N urSuaXPg4SxDQbqTgY0blRxBOVnv3lEasCN8wZtUrAfDPiqh4iTb125WqoY8SmgXFU2J EqnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=QHOm3Gw7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id l19-20020a656813000000b0056b0b30d05csi3151607pgt.245.2023.09.15.04.37.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 04:37:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=QHOm3Gw7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 9FBA283B6E20; Fri, 15 Sep 2023 01:29:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232141AbjIOI3J (ORCPT + 99 others); Fri, 15 Sep 2023 04:29:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232435AbjIOI3H (ORCPT ); Fri, 15 Sep 2023 04:29:07 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D76D72720 for ; Fri, 15 Sep 2023 01:27:18 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1c364fb8a4cso17244315ad.1 for ; Fri, 15 Sep 2023 01:27:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1694766438; x=1695371238; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=/d7/3Obm53ZQCMrVF3c99mLRUxxcGODrgFkkmXmmWh0=; b=QHOm3Gw7e6m6el/CLOvbN5PcwyOqHuMKAwNywmcAq4L4eqF2Mgxl9GdN1ZA3Nh2Tk7 Y878T6k/NpsbZyZxxVorq9gZufaU3ua0cXqlexHmVLoOjAqIyiyw1y4w16k8GqoYgL9i yLBv3TmQ7cL4QRFbNuvvDs30fZGaDRnxYAdzMZjG5zkDweYr7zBD/1rb+pnHp55WCtaS jhhwfB/aiQAvXhILJCDF6tr0NS487cnNq4fax2A0hPP/j0oDeGoaBCeNQbh327KhjH+n H6+Onp5R+d+dL6Joh9SorYvMVrTbzdUbDt+YZrJELwFLZ5KoPRBYwp0dMEEhtUH7lH9H 0iqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694766438; x=1695371238; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/d7/3Obm53ZQCMrVF3c99mLRUxxcGODrgFkkmXmmWh0=; b=ThVoeju3hBU5R2tVrd2E1zKRoyvD8dltDYCBMqoCIItIcCXY5OrMT9Plhlp/GGSAuy WIPCkzFBAQknMs49Ky7G2xxWu13BlVv09ak1q21IkhiObB9+wKWp+bx9vLlB/+v4gHEQ cdyF8BmoRceHxQfmGEfGN8mjSm/W4rf+EzZSNh7++ICoEELubiyhTWNc5TLgQ7YbSJxp MUqomfqNrmuCNjt1xk81k27utaKOEg72OplvG7S0cWM5Td+dp8x1R3vK/xaFCn6gZj7E iWV0bfXeID5TbiRCMbPY2bunUxVelSsleZZHsIuYHle/UfeJqVU9CHOveX7uFiKedNOC +zIQ== X-Gm-Message-State: AOJu0Yz7opQqMHi4bQLJMEBkBpOl/rhkLHnJ8XyddtrrFihmsAYhiGYk uqFYQ/bswpx0gISwN2OiM7uzzw== X-Received: by 2002:a17:902:d2cd:b0:1c3:e5bf:a9f8 with SMTP id n13-20020a170902d2cd00b001c3e5bfa9f8mr1188084plc.19.1694766438315; Fri, 15 Sep 2023 01:27:18 -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 f4-20020a170902ab8400b001c0af36dd64sm2912806plr.162.2023.09.15.01.27.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 01:27:18 -0700 (PDT) From: Yong-Xuan Wang To: linux-riscv@lists.infradead.org, kvm-riscv@lists.infradead.org Cc: greentime.hu@sifive.com, vincent.chen@sifive.com, tjytimi@163.com, alex@ghiti.fr, Yong-Xuan Wang , Paul Walmsley , Palmer Dabbelt , Albert Ou , Anup Patel , Guo Ren , Andrew Jones , Conor Dooley , wchen , Heiko Stuebner , Jisheng Zhang , Andrew Morton , Alexandre Ghiti , Kemeng Shi , David Hildenbrand , Sergey Matyukevich , "Matthew Wilcox (Oracle)" , Charlie Jenkins , Qinglin Pan , Rick Edgecombe , Evan Green , Sunil V L , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] RISC-V: Detect and Enable Svadu Extension Support Date: Fri, 15 Sep 2023 08:26:57 +0000 Message-Id: <20230915082701.3643-2-yongxuan.wang@sifive.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230915082701.3643-1-yongxuan.wang@sifive.com> References: <20230915082701.3643-1-yongxuan.wang@sifive.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 groat.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 (groat.vger.email [0.0.0.0]); Fri, 15 Sep 2023 01:29:10 -0700 (PDT) We detect Svadu extension support from DTB and add arch_has_hw_pte_young() to enable optimization in MGLRU and __wp_page_copy_user() if Svadu extension is available. Signed-off-by: Jinyu Tang Signed-off-by: Yong-Xuan Wang --- arch/riscv/include/asm/csr.h | 1 + arch/riscv/include/asm/hwcap.h | 1 + arch/riscv/include/asm/pgtable.h | 6 ++++++ arch/riscv/kernel/cpufeature.c | 1 + 4 files changed, 9 insertions(+) diff --git a/arch/riscv/include/asm/csr.h b/arch/riscv/include/asm/csr.h index 777cb8299551..10648b372a2a 100644 --- a/arch/riscv/include/asm/csr.h +++ b/arch/riscv/include/asm/csr.h @@ -194,6 +194,7 @@ /* xENVCFG flags */ #define ENVCFG_STCE (_AC(1, ULL) << 63) #define ENVCFG_PBMTE (_AC(1, ULL) << 62) +#define ENVCFG_HADE (_AC(1, ULL) << 61) #define ENVCFG_CBZE (_AC(1, UL) << 7) #define ENVCFG_CBCFE (_AC(1, UL) << 6) #define ENVCFG_CBIE_SHIFT 4 diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwcap.h index b7b58258f6c7..1013661d6516 100644 --- a/arch/riscv/include/asm/hwcap.h +++ b/arch/riscv/include/asm/hwcap.h @@ -58,6 +58,7 @@ #define RISCV_ISA_EXT_ZICSR 40 #define RISCV_ISA_EXT_ZIFENCEI 41 #define RISCV_ISA_EXT_ZIHPM 42 +#define RISCV_ISA_EXT_SVADU 43 #define RISCV_ISA_EXT_MAX 64 diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index b2ba3f79cfe9..f3d077dff8ac 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -629,6 +629,12 @@ static inline pgprot_t pgprot_writecombine(pgprot_t _prot) return __pgprot(prot); } +#define arch_has_hw_pte_young arch_has_hw_pte_young +static inline bool arch_has_hw_pte_young(void) +{ + return riscv_has_extension_likely(RISCV_ISA_EXT_SVADU); +} + /* * THP functions */ diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c index 1cfbba65d11a..ead378c04991 100644 --- a/arch/riscv/kernel/cpufeature.c +++ b/arch/riscv/kernel/cpufeature.c @@ -178,6 +178,7 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = { __RISCV_ISA_EXT_DATA(ssaia, RISCV_ISA_EXT_SSAIA), __RISCV_ISA_EXT_DATA(sscofpmf, RISCV_ISA_EXT_SSCOFPMF), __RISCV_ISA_EXT_DATA(sstc, RISCV_ISA_EXT_SSTC), + __RISCV_ISA_EXT_DATA(svadu, RISCV_ISA_EXT_SVADU), __RISCV_ISA_EXT_DATA(svinval, RISCV_ISA_EXT_SVINVAL), __RISCV_ISA_EXT_DATA(svnapot, RISCV_ISA_EXT_SVNAPOT), __RISCV_ISA_EXT_DATA(svpbmt, RISCV_ISA_EXT_SVPBMT), -- 2.17.1