From patchwork Wed Apr 19 22:16:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 85582 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp698541vqo; Wed, 19 Apr 2023 15:19:19 -0700 (PDT) X-Google-Smtp-Source: AKy350bWoGjIfQqcgVRQJlRRD9VLXC8OZrT2J76pSMdBMMsHy1QFK1llTtDHI+ZxjUcIhLOZd7rk X-Received: by 2002:a05:6a21:2d8d:b0:ef:ba1a:e7b9 with SMTP id ty13-20020a056a212d8d00b000efba1ae7b9mr86788pzb.28.1681942759225; Wed, 19 Apr 2023 15:19:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681942759; cv=none; d=google.com; s=arc-20160816; b=N7c87KBUHdjHpMgNAQ13XLmfvvB9eLN9rC0fbGtluZUGrwCgZpoV9vCkLMOcwoPoXc PatrbX+QrBOhIfi50ENj1Kfd6KNusYmqNT3ygfCrGWn5grb0sxxNlPwTtd7B0B826+kp 3QPucPr94F5oKiHdZJLkPD9DRoMEuuHOD33SpUz3Y0NA9F5N8qInQJt+oSuZnl4P38z3 +zy36i8iA4ohW2YmL3K+2LQJac99gjdiJcyHxGUg4bL+BYhZszmHuZIXBrciL6ZWEfgW nDDdo23YP/EPOPeD1h3tyRxJ4sEkkqy6sdifGz706wIKn7psLslFYoNUKI77B91p7kRB famw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ur77tHINwX+qbUdlSGnRNMwUnwDaAVVcewhgSBhFUx0=; b=ufIvj2/XazBug/7/WQw1o+M8G1DmXJ/1QyTkt06FnQ5QxlUTvV3CA3RwcdBww1k3V3 48kc0cHeE4JrIv0amcYQByikje58zLac5v4xGtaI/DpQO0zQieYA9rn3R6BFfnrQK4sK 7omIkzmDlQ9wstNQ4jjVRvjjYKykVlwjrY6wFk+mIQd48aASpk/eKNrzqDswvp5Jbi+b LMC3yGPt9jMxUCa2v2heV/dyKP/XpiwpTynmT0uVkShCjXQp9o0kJHp2TkuwubYOoiJ3 rlYZCqM4fTxHeV4/GknrSASijTiNNP0GdO/GKJMnxPv4+l8hfROJU0JehvlmclRiT/zU 6APA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=c18b6Hjh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f16-20020a63f110000000b00520a879b9cesi2569287pgi.3.2023.04.19.15.19.05; Wed, 19 Apr 2023 15:19:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=c18b6Hjh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231474AbjDSWR4 (ORCPT + 99 others); Wed, 19 Apr 2023 18:17:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229793AbjDSWRk (ORCPT ); Wed, 19 Apr 2023 18:17:40 -0400 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12C821718 for ; Wed, 19 Apr 2023 15:17:39 -0700 (PDT) Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-524b02cc166so64221a12.0 for ; Wed, 19 Apr 2023 15:17:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1681942658; x=1684534658; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ur77tHINwX+qbUdlSGnRNMwUnwDaAVVcewhgSBhFUx0=; b=c18b6HjhB6xZTijYQX2nimbdoBlIXr9qBNm2sHraX79sumJ2mnHyyAF4iUwGRyqfEL BhG5ZneVkTF9bRo5tCCiGvsNVcpWUKCNmPy0vd1ZqJvuNoQxq1qR6f9cnB7vi+C19Hpt 5xUpfFR1k+6B8FbGHFbFXaZtvW/H2sqgRRevhtG9hluShqAQzpot/WQd/qsXuDNgOnpx pk3tmGjn1iUOEgqZ0Ek3rQdbQ5Ky98ttJ9TAom0YVfPe7HTavUoUAmMw/LDuEdRosyc4 CHRnQ9rCEYyXJCmVNUHBEGkpIQ2ljog3inmdpJcdTAOUNGgtwJP32aGziItUDdOFTV+8 kKew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681942658; x=1684534658; h=content-transfer-encoding:mime-version: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=ur77tHINwX+qbUdlSGnRNMwUnwDaAVVcewhgSBhFUx0=; b=fLMJ2VtdZliSRcJ4JmEFRare4caZIk5hSSto2Evw/0ZbLPXL7Da8iyHG4fsqO6OzkQ 3Da4immakuz1Ee5JO2ASqqh1Qy4iUD9b8HR700H7AhObf16GOsONzULnQybAzFgwLyoQ 6kxw4ZEUG8HYqySAIT20K7L4D0niAsZWf0k/BsZ0IQomhWhbfxhFiuPA7EO/xCCuEb39 gdQWXcPIqqf2zIOhwpj33Li4g0Yi3PpUtO86fYmz4TB3kq7uTVlWi2QqfcZazlana83D US9iAkunXCHFwCW8sFNJCLB0TfDzQZpd6G7ucs8qfUYBsrH1xs/mv0z0kv0zNy35y3ga wpvw== X-Gm-Message-State: AAQBX9dpS0gaVQ+IEjdAg3AO000k6RvWE5BAjbaFNqrj42N0yICPjFmQ VQEUruW6hq7+DF5xH5DpHgQVnW8ptufUoEYYq8Q= X-Received: by 2002:a17:903:1210:b0:1a6:4a64:4d27 with SMTP id l16-20020a170903121000b001a64a644d27mr7782580plh.40.1681942658444; Wed, 19 Apr 2023 15:17:38 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id jn11-20020a170903050b00b00196807b5189sm11619190plb.292.2023.04.19.15.17.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 15:17:38 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Alexandre Ghiti , Andrew Jones , Andrew Morton , Anup Patel , Atish Patra , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Suzuki K Poulose , Will Deacon , Marc Zyngier , Sean Christopherson , linux-coco@lists.linux.dev, Dylan Reid , abrestic@rivosinc.com, Samuel Ortiz , Christoph Hellwig , Conor Dooley , Greg Kroah-Hartman , Guo Ren , Heiko Stuebner , Jiri Slaby , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, Mayuresh Chitale , Palmer Dabbelt , Paolo Bonzini , Paul Walmsley , Rajnesh Kanwal , Uladzislau Rezki Subject: [RFC 04/48] RISC-V: KVM: Add a helper function to get pgd size Date: Wed, 19 Apr 2023 15:16:32 -0700 Message-Id: <20230419221716.3603068-5-atishp@rivosinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230419221716.3603068-1-atishp@rivosinc.com> References: <20230419221716.3603068-1-atishp@rivosinc.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763644810387643507?= X-GMAIL-MSGID: =?utf-8?q?1763644810387643507?= The cove support will require to find out the pgd size to be used for the gstage page table directory. Export the value via an additional helper. Signed-off-by: Atish Patra --- arch/riscv/include/asm/kvm_host.h | 1 + arch/riscv/kvm/mmu.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/arch/riscv/include/asm/kvm_host.h b/arch/riscv/include/asm/kvm_host.h index 8714325..63c46af 100644 --- a/arch/riscv/include/asm/kvm_host.h +++ b/arch/riscv/include/asm/kvm_host.h @@ -313,6 +313,7 @@ void kvm_riscv_gstage_update_hgatp(struct kvm_vcpu *vcpu); void __init kvm_riscv_gstage_mode_detect(void); unsigned long __init kvm_riscv_gstage_mode(void); int kvm_riscv_gstage_gpa_bits(void); +unsigned long kvm_riscv_gstage_pgd_size(void); void __init kvm_riscv_gstage_vmid_detect(void); unsigned long kvm_riscv_gstage_vmid_bits(void); diff --git a/arch/riscv/kvm/mmu.c b/arch/riscv/kvm/mmu.c index f0fff56..6b037f7 100644 --- a/arch/riscv/kvm/mmu.c +++ b/arch/riscv/kvm/mmu.c @@ -797,3 +797,8 @@ int kvm_riscv_gstage_gpa_bits(void) { return gstage_gpa_bits; } + +unsigned long kvm_riscv_gstage_pgd_size(void) +{ + return gstage_pgd_size; +}