Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4850636iob; Mon, 9 May 2022 03:10:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUGNXWkvciZa21gj1kfQPjAeeaA1BWj3FOfn/3Z4VvTFNUI6J0hNBthYSi+3nFMWS+THGU X-Received: by 2002:a17:902:eb87:b0:15e:bd77:a91 with SMTP id q7-20020a170902eb8700b0015ebd770a91mr15528618plg.49.1652091010036; Mon, 09 May 2022 03:10:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652091010; cv=none; d=google.com; s=arc-20160816; b=VoMsA0M6uGadI67NDJk0jIA6NdJCIy3WUI2UzaUTbhf30m0BvNBi8AzWkHED5gnWDV FbPxKPHvUkxcGBmDljxM2AhDQJVwunK6FNoTAMdVlxp8/pj03f+pZeskyLyf/4wKw4dx Xyv85HY6lKbuWiRGqfrTPFc5BLVSrTz9PuryoKn2+cqfMy3b8nqxSqPYk5FcS6hMsk1t 2rUbBXiPhZYQsCWJv76lFE7or/PH5P73DucwEPiUs33ZcCj0lmpqS0GIeUJ7fA3FSZEv 9q6+ZCTU+Z5ZdHxMzp1ymEFCv5i3rB06djF1mCadJHRNOvCpi6mwBbae72l9+N1aChSw nzdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=LcfykvzzxOiiw+jUTB5oG4jSYC/kWrfsWiX4vYPyo9M=; b=JtgdSBbtnosl/mTRyK8BryWnbXNGbQmCbB4O9Oe1xT4mxvylGPTR0Ih27ZR/Q9wl7d ICYDmI++6F0K92bjpRMuaHCL3W9xe1pWfRkbIp7CVc/s9eYorjsPgb0tjabcxHNRQTyn 4hbxGyCloIkoPFphdtj3JfTjbjQBMqrU97WaM3aQn7cr+Nwpc6vUg53h9cFPKn02Ca5B DaKXn56xsnWcLqhcL8ewTDT3klVQ/o65M7an2OrKtfWwmdWctkc79tPQlDULb7heWTvZ /Vo8inH48Wh//YCKr6+RpZpeuIdcR5oYsvGqGkmDbr2ebbJcIWtAACSgrxwWu/BM+F1y znnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=kcIUmvvt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id l2-20020a170902f68200b00153b2d16540si13290730plg.328.2022.05.09.03.10.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 03:10:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@brainfault-org.20210112.gappssmtp.com header.s=20210112 header.b=kcIUmvvt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1DEBB227CE6; Mon, 9 May 2022 02:49:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230252AbiEIFh1 (ORCPT + 99 others); Mon, 9 May 2022 01:37:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231927AbiEIFgF (ORCPT ); Mon, 9 May 2022 01:36:05 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF959149170 for ; Sun, 8 May 2022 22:32:10 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id n126-20020a1c2784000000b0038e8af3e788so7599224wmn.1 for ; Sun, 08 May 2022 22:32:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LcfykvzzxOiiw+jUTB5oG4jSYC/kWrfsWiX4vYPyo9M=; b=kcIUmvvtYBneIxYWYiv7+ZFh4noeZ8Am8LxJbwy0tzXZr9y8d+KI/QsxlJYsuNmM08 OGVALXNd+CoIDFW0iCeuANfBqIyQS40FLvfNaMi065NgKl77XGww480iffDwl6iePFnE /vJB/ZxTrHlkneSUP3qUDzxPQAp3k9HVD/gzvdtZ1VCKGBwXgKM82C1otDJIg0CsWkjK vsabX+kfPaNfmRig6dYdjkMY9DINlp5EnFbw/ugfF3n9ZVJn+hGULwm5aCit+DiPEilU PCSa4bC99EGefh/P+fD5m0E04J6FnoNl2PNtaY0heLJiAHpFynaawAWRjO/PVQgC5jjR TvSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LcfykvzzxOiiw+jUTB5oG4jSYC/kWrfsWiX4vYPyo9M=; b=iJDpceZyz7JoaYgY0gGuIgCFWOgt1culGYrEDm90GxS2m82XR8A44YldhSws/LHtmR J0HSh7M31PoS4ub613QDPae7p0ndyWpSpTyzGjSLn4kZ8pc0SCewyYSAe2Zma9vElPT0 WVZ3dLJYjuH8os0wRMDVkH3Hjk36a4v2ouAmYY7PTy51jYZCi5TuLq1zcwf6bCs0r8Qv oJxJQgplIUcr+LT6+sVvVvyKBB0ecMrFX1kurYwGU5jNDjv50AuZvZ/SoRks3y1gwLOm dxyNkk4TzYuJYAqghHcnV4Hsm/syaj00vO2MvIQB9mm2pEAGlji/FJDVPJF7bV4YgLW9 y7iQ== X-Gm-Message-State: AOAM532OCXfxW1FXiXI7uhA2Zw1+rufBO0+hIGoAxnDwO8/TaRF84wCf ylzJ3hOxZjRt0V9rLiC6+aCNRb+XPyXPrBALVgq+QQ== X-Received: by 2002:a05:600c:3caa:b0:394:8fb8:716 with SMTP id bg42-20020a05600c3caa00b003948fb80716mr3550006wmb.105.1652074328778; Sun, 08 May 2022 22:32:08 -0700 (PDT) MIME-Version: 1.0 References: <20220420112450.155624-1-apatel@ventanamicro.com> <20220420112450.155624-3-apatel@ventanamicro.com> In-Reply-To: From: Anup Patel Date: Mon, 9 May 2022 11:01:57 +0530 Message-ID: Subject: Re: [PATCH v2 2/7] RISC-V: KVM: Add Sv57x4 mode support for G-stage To: Atish Patra Cc: Anup Patel , Paolo Bonzini , Palmer Dabbelt , Paul Walmsley , Alistair Francis , KVM General , "open list:KERNEL VIRTUAL MACHINE FOR RISC-V (KVM/riscv)" , linux-riscv , "linux-kernel@vger.kernel.org List" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 4, 2022 at 7:44 AM Atish Patra wrote: > > On Wed, Apr 20, 2022 at 4:25 AM Anup Patel wrote: > > > > Latest QEMU supports G-stage Sv57x4 mode so this patch extends KVM > > RISC-V G-stage handling to detect and use Sv57x4 mode when available. > > > > Signed-off-by: Anup Patel > > --- > > arch/riscv/include/asm/csr.h | 1 + > > arch/riscv/kvm/main.c | 3 +++ > > arch/riscv/kvm/mmu.c | 11 ++++++++++- > > 3 files changed, 14 insertions(+), 1 deletion(-) > > > > diff --git a/arch/riscv/include/asm/csr.h b/arch/riscv/include/asm/csr.h > > index e935f27b10fd..cc40521e438b 100644 > > --- a/arch/riscv/include/asm/csr.h > > +++ b/arch/riscv/include/asm/csr.h > > @@ -117,6 +117,7 @@ > > #define HGATP_MODE_SV32X4 _AC(1, UL) > > #define HGATP_MODE_SV39X4 _AC(8, UL) > > #define HGATP_MODE_SV48X4 _AC(9, UL) > > +#define HGATP_MODE_SV57X4 _AC(10, UL) > > > > #define HGATP32_MODE_SHIFT 31 > > #define HGATP32_VMID_SHIFT 22 > > diff --git a/arch/riscv/kvm/main.c b/arch/riscv/kvm/main.c > > index c374dad82eee..1549205fe5fe 100644 > > --- a/arch/riscv/kvm/main.c > > +++ b/arch/riscv/kvm/main.c > > @@ -105,6 +105,9 @@ int kvm_arch_init(void *opaque) > > case HGATP_MODE_SV48X4: > > str = "Sv48x4"; > > break; > > + case HGATP_MODE_SV57X4: > > + str = "Sv57x4"; > > + break; > > default: > > return -ENODEV; > > } > > diff --git a/arch/riscv/kvm/mmu.c b/arch/riscv/kvm/mmu.c > > index dc0520792e31..8823eb32dcde 100644 > > --- a/arch/riscv/kvm/mmu.c > > +++ b/arch/riscv/kvm/mmu.c > > @@ -751,14 +751,23 @@ void kvm_riscv_gstage_update_hgatp(struct kvm_vcpu *vcpu) > > void kvm_riscv_gstage_mode_detect(void) > > { > > #ifdef CONFIG_64BIT > > + /* Try Sv57x4 G-stage mode */ > > + csr_write(CSR_HGATP, HGATP_MODE_SV57X4 << HGATP_MODE_SHIFT); > > + if ((csr_read(CSR_HGATP) >> HGATP_MODE_SHIFT) == HGATP_MODE_SV57X4) { > > + gstage_mode = (HGATP_MODE_SV57X4 << HGATP_MODE_SHIFT); > > + gstage_pgd_levels = 5; > > + goto skip_sv48x4_test; > > + } > > + > > /* Try Sv48x4 G-stage mode */ > > csr_write(CSR_HGATP, HGATP_MODE_SV48X4 << HGATP_MODE_SHIFT); > > if ((csr_read(CSR_HGATP) >> HGATP_MODE_SHIFT) == HGATP_MODE_SV48X4) { > > gstage_mode = (HGATP_MODE_SV48X4 << HGATP_MODE_SHIFT); > > gstage_pgd_levels = 4; > > } > > - csr_write(CSR_HGATP, 0); > > +skip_sv48x4_test: > > > > + csr_write(CSR_HGATP, 0); > > __kvm_riscv_hfence_gvma_all(); > > #endif > > } > > -- > > 2.25.1 > > > > Reviewed-by: Atish Patra Queued this patch for 5.19 Thanks, Anup > > -- > Regards, > Atish