From nobody Wed Dec 17 15:39:58 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09752C77B73 for ; Wed, 19 Apr 2023 22:35:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229991AbjDSWf5 (ORCPT ); Wed, 19 Apr 2023 18:35:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232494AbjDSWfz (ORCPT ); Wed, 19 Apr 2023 18:35:55 -0400 Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 236131FF0 for ; Wed, 19 Apr 2023 15:35:23 -0700 (PDT) Received: by mail-qk1-x731.google.com with SMTP id af79cd13be357-74db3642400so4729885a.2 for ; Wed, 19 Apr 2023 15:35:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1681943660; x=1684535660; 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=iv3jO/UplLaGK+gTx4v9j9xexh60oYjru3uhX3LfGtA=; b=1vPSyerqCt0Qvmv8hwWhHs7+2v7XZAr0KTtgrWL8gjgqfbN4dFPAoAdZKUnWg12ZG3 /YHqSNVuzXAc9b2HHwGH9LBzvgZToUvEu35LDcgR6A9q+XF7KMusQr66TDyHOeFfFrqL dYumZcibZ88UIV3XDd3fu8JgdSeCCADimOXm4NTSmIIENw4jPwsywDQ3Dvfh8vZnU/VF 2cQlWu4iJNzDcz9iAaE1D4BTPYin8nFfRQVUj76zTk1WFPDT9V13d7wvFhn1zjsBbPJz TBf25knHEobu9uNSG14nviJCdobDDbdi9UhzhOzvayqzCnYVdfHDjyFSJBIaB5RURPTv KQ8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681943660; x=1684535660; 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=iv3jO/UplLaGK+gTx4v9j9xexh60oYjru3uhX3LfGtA=; b=L4w2dO7/4ZuIxP1G0+Wn9kt8CVgDVUi/gI0hkk8ojWwr6XeZzZv69dZYxSdLyq5qjG sBp6nF81qeei3SiuatExzpb+ZAjC/ig82w07KHTvwi5UELsuX1T/KL1ts/yCJSgdydK3 571fJAvscfbynHsIliNcEiMlkEhMzNpZXhGLGSNhfCJDG441qCCfZIFYI2394AN83yYR w8OsPRJ6cHGtGRqzY4U3eEFjDHi8/H2TdNB4myW962lpg8eP69MgrnNcMFDYIN+Be8Y0 VnJ64yJYj3jDuefIQIld0Ma64n3EJoiGgZ8+MgjmVpjFQ4Hzt7tbgMkyykEY8AuJmpU9 61Lg== X-Gm-Message-State: AAQBX9ccwH5NOh1fT91hVPy/TBb/yQydAVlP7gSQ2kWKzmSmWAoD8kkc +nYv2euUigyKNFoAH3GJQtVCTglKd2sdXD+kyjY= X-Google-Smtp-Source: AKy350YmjLuFNHpdbGKVUxtLnNGDTOqZujizSNNxdVNVjL7P36ZiZ6Z6Phv1PaiPaoxLg0i7OBeTQw== X-Received: by 2002:a17:902:d505:b0:19d:778:ff5 with SMTP id b5-20020a170902d50500b0019d07780ff5mr7467330plg.15.1681943057246; Wed, 19 Apr 2023 15:24:17 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id e4-20020a170902744400b001a681fb3e77sm11867810plt.44.2023.04.19.15.24.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 15:24:17 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Rajnesh Kanwal , Alexandre Ghiti , Andrew Jones , Andrew Morton , Anup Patel , Atish Patra , Suzuki K Poulose , Will Deacon , Marc Zyngier , Sean Christopherson , linux-coco@lists.linux.dev, Dylan Reid , abrestic@rivosinc.com, Samuel Ortiz , Jiri Slaby , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, Palmer Dabbelt , Paolo Bonzini , Uladzislau Rezki Subject: [RFC kvmtool 08/10] riscv: virtio: Enforce VIRTIO_F_ACCESS_PLATFORM feature flag. Date: Wed, 19 Apr 2023 15:23:48 -0700 Message-Id: <20230419222350.3604274-9-atishp@rivosinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230419222350.3604274-1-atishp@rivosinc.com> References: <20230419222350.3604274-1-atishp@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Rajnesh Kanwal VIRTIO_F_ACCESS_PLATFORM feature tells the guest that device will be using DMA for transfers. This forces the guest to use DMA API to allow the host to successfully access guest memory as needed. This is needed for CoVE VMs. Signed-off-by: Rajnesh Kanwal --- riscv/kvm.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/riscv/kvm.c b/riscv/kvm.c index e728790..aebb6bd 100644 --- a/riscv/kvm.c +++ b/riscv/kvm.c @@ -7,6 +7,7 @@ #include #include #include +#include =20 struct kvm_ext kvm_req_ext[] =3D { { DEFINE_KVM_EXT(KVM_CAP_ONE_REG) }, @@ -224,5 +225,14 @@ int kvm__arch_setup_firmware(struct kvm *kvm) =20 u64 kvm__arch_get_virtio_host_features(struct kvm *kvm) { - return 0; + u64 features =3D 0; + + /* CoVE VMs mandate VIRTIO_F_ACCESS_PLATFORM feature to force use of + * SWIOTLB bounce buffers through DMA API. Without this device probe + * will fail for CoVE VMs. + */ + if (kvm->cfg.arch.cove_vm) + features |=3D (1ULL << VIRTIO_F_ACCESS_PLATFORM); + + return features; } --=20 2.25.1