Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp722775rdg; Wed, 11 Oct 2023 03:54:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGjxRyRE9SM2eKFQbj4bGb7QcOnI2vmWdVabJspZ8nxvILPmVGTPPLgscJp+eTn9o/TaLCE X-Received: by 2002:a17:902:e843:b0:1c9:b786:3c1e with SMTP id t3-20020a170902e84300b001c9b7863c1emr4338188plg.5.1697021692187; Wed, 11 Oct 2023 03:54:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697021692; cv=none; d=google.com; s=arc-20160816; b=vpnOfbKHXHNKemsthsa+KO1KHlUPwal4DMnJRrSBZpJkVjc62ZgzULoUjyTNQOm5et Kd9gS9R3J9VpoLPqmBnfLifHf4Cf1OXBQnQSZ6jJFJ0wefvGSib4bc/gCRXTg7xF7DUo 0rxQMMmvk29TxAECwf+Y7RmS9OE4rghji5U7CEseGlOpK4nsnXOk0j1DT/okZjP+2mcl 853viy4UayfupCHPCVTv+f/CJOr55ZEdrE/cOoLsd41Ev31vT+Y1IakytWj2Qc7ARjbR FJZmW1UHyuMF9PBxlQmfPUW7UoZGdpM7VMu4rHwImeCpsCpWtcBW7E4Nl9Bl55AxbYGx +R5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=p4nF6PEutWJBQPD4LIT1skkD09xa4qGsBtRI6mZk9kM=; fh=JyL8+fJr4BsolHUmcm+dYi0xCmNZZ71zno4Ij1nE8wE=; b=kwUe88lRyz8i0vjndRRcFcXnwuvIUqv43h1cBbGZRTvaUchuJXFEUHh/MF+oRgYAyK IMYT+ky197VfHJ+i9GgKIQEe/AjrdKtTNCZMJXDwilkfiLut7T9Q+VJtnCwVGOKzWYv/ cMmjF7EnO7m/7G4BiMuCLZLUrTtd6hhcKbm7HKi7c7zeb8Q13tXLWfQUob/P5WD+dNJm 0oV+vQ6cTaRw0Lq5+/o8BpWp3zyX22Jd31wB1eY1oeXZvTBx755R4/495jn0izOj4avZ TX1GU+2b1YO6/CRda1JR/sbBDnO1cVjA+iLwLzvswmT2YPyFyO/QAKIGDEZOTgxDXjs1 e66Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=LO+VbWoG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id a8-20020a170902ecc800b001c9af06686dsi4586565plh.166.2023.10.11.03.54.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:54:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=LO+VbWoG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id D9B7581B894E; Wed, 11 Oct 2023 03:54:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234808AbjJKKyp (ORCPT + 99 others); Wed, 11 Oct 2023 06:54:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234802AbjJKKyn (ORCPT ); Wed, 11 Oct 2023 06:54:43 -0400 Received: from mail-vs1-xe31.google.com (mail-vs1-xe31.google.com [IPv6:2607:f8b0:4864:20::e31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0E6592 for ; Wed, 11 Oct 2023 03:54:40 -0700 (PDT) Received: by mail-vs1-xe31.google.com with SMTP id ada2fe7eead31-452951b27d0so2827331137.2 for ; Wed, 11 Oct 2023 03:54:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1697021680; x=1697626480; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=p4nF6PEutWJBQPD4LIT1skkD09xa4qGsBtRI6mZk9kM=; b=LO+VbWoGycURW0lZWdLoS/PCw4dvNGHkODJzJRAUvngwyubXTbZmkcxI1LxdnqXjQ0 tzC3qwSQaqLZW1rIcbypgWPF43TKDA1x2hNTPaSmfshPGmGHGIfnUUu3Mh2xCeMC0x8Y gSlfAMdlmU81u4S4uWARRLJ+Hj/7G+XQkP+vak0jx2ATtR2AuxNGOufYOpgEyXnHcPOx DKFIJAgnbyG63kE2E1j5vdX7aYuwc/0e5+hbcU+4SvPbdzOVjnZmyNHcxgAgSWn5LSwU XPCNgora0K24vvGw5oZHx7cUs3moAhmK07q24JM6Bh8Y1ffUD/nlUQizpL1IxDytNttD GOHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697021680; x=1697626480; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=p4nF6PEutWJBQPD4LIT1skkD09xa4qGsBtRI6mZk9kM=; b=sZOAx+EXj1q4gHlu3pEobctB7M20SAm6+DSu0n+nY7oWH0t7Iv/7AAyaiTGQag83xq E72NlwTDHAUaJVeENQNMKQkWlwMEkZOD42DMiOwPn1o5In0AA4NgTEWngYYM3RdGzb/1 y6jK+b1Xt9QoHYxRjy0MOvZPpmr+/OnNzEn/rqL3XlP5Wde7puVQonysDYs63yEazt/1 srwRpl8pYQ4/hPXh79M9CQvDtFm1SnWbEKuhb6yZSqYRYbf6Redc9ATysu9nGWrbPPEp 0jLvh8ZX/yQpxwPB4VOZiH/LsKuJ7P7/qQ1iySlkMUB3BaMtQ5Yf1oI47or7+u3ZOOHF YIOQ== X-Gm-Message-State: AOJu0YxJoqH8brBhhvdMgxMxdZRuqjpNVJUxjXuZ68a4kOc2LNbfYZ2r IRo8Gh3/SkGYPQ82FW+FbweQ+PbI/S0/L2yAc4Qsnw== X-Received: by 2002:a67:cd11:0:b0:450:8e58:2de4 with SMTP id u17-20020a67cd11000000b004508e582de4mr18396034vsl.7.1697021679643; Wed, 11 Oct 2023 03:54:39 -0700 (PDT) MIME-Version: 1.0 References: <20231010170503.657189-1-apatel@ventanamicro.com> <20231010170503.657189-4-apatel@ventanamicro.com> <2023101048-attach-drift-d77b@gregkh> <2023101105-oink-aerospace-989e@gregkh> In-Reply-To: <2023101105-oink-aerospace-989e@gregkh> From: Anup Patel Date: Wed, 11 Oct 2023 16:24:28 +0530 Message-ID: Subject: Re: [PATCH 3/6] RISC-V: KVM: Forward SBI DBCN extension to user-space To: Greg Kroah-Hartman Cc: Paolo Bonzini , Atish Patra , Palmer Dabbelt , Paul Walmsley , Jiri Slaby , Conor Dooley , Andrew Jones , kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-serial@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 11 Oct 2023 03:54:51 -0700 (PDT) On Wed, Oct 11, 2023 at 12:56=E2=80=AFPM Greg Kroah-Hartman wrote: > > On Wed, Oct 11, 2023 at 12:02:30PM +0530, Anup Patel wrote: > > On Tue, Oct 10, 2023 at 10:45=E2=80=AFPM Greg Kroah-Hartman > > wrote: > > > > > > On Tue, Oct 10, 2023 at 10:35:00PM +0530, Anup Patel wrote: > > > > The SBI DBCN extension needs to be emulated in user-space > > > > > > Why? > > > > The SBI debug console is similar to a console port available to > > KVM Guest so the KVM user space tool (i.e. QEMU-KVM or > > KVMTOOL) can redirect the input/output of SBI debug console > > wherever it wants (e.g. telnet, file, stdio, etc). > > > > We forward SBI DBCN calls to KVM user space so that the > > in-kernel KVM does not need to be aware of the guest > > console devices. > > Hint, my "Why" was attempting to get you to write a better changelog > description, which would include the above information. Please read the > kernel documentation for hints on how to do this so that we know what > why changes are being made. Okay, I will improve the commit description and cover-letter. > > > > > so let > > > > us forward console_puts() call to user-space. > > > > > > What could go wrong! > > > > > > Why does userspace have to get involved in a console message? Why is > > > this needed at all? The kernel can not handle userspace consoles as > > > obviously they have to be re-entrant and irq safe. > > > > As mentioned above, these are KVM guest console messages which > > the VMM (i.e. KVM user-space) can choose to manage on its own. > > If it chooses not to, what happens? If KVM user-space chooses not to handle SBI DBCN calls then it can disable SBI DBCN extension for Guest VCPUs using the ONE_REG ioctl() interface. > > > This is more about providing flexibility to KVM user-space which > > allows it to manage guest console devices. > > Why not use the normal virtio console device interface instead of making > a riscv-custom one? The SBI DBCN (or debug console) is only an early console used for early prints and bootloaders. Once the proper console (like virtio console) is detected by the Guest kernel, it will switch the debug console to proper console. > > Where is the userspace side of this interface at? Where are the patches > to handle this new api you added? As mentioned in the cover letter, I have implemented it in KVMTOOL first. The patches can be found in riscv_sbi_dbcn_v1 branch at: https://github.com/avpatel/kvmtool.git More precisely, this commit: https://github.com/avpatel/kvmtool/commit/06a373ee8991f882ef79de3845a4c8d63= cb189a6 > > > > > > > > > > > > > > Signed-off-by: Anup Patel > > > > --- > > > > arch/riscv/include/asm/kvm_vcpu_sbi.h | 1 + > > > > arch/riscv/include/uapi/asm/kvm.h | 1 + > > > > arch/riscv/kvm/vcpu_sbi.c | 4 ++++ > > > > arch/riscv/kvm/vcpu_sbi_replace.c | 31 +++++++++++++++++++++++= ++++ > > > > 4 files changed, 37 insertions(+) > > > > > > > > diff --git a/arch/riscv/include/asm/kvm_vcpu_sbi.h b/arch/riscv/inc= lude/asm/kvm_vcpu_sbi.h > > > > index 8d6d4dce8a5e..a85f95eb6e85 100644 > > > > --- a/arch/riscv/include/asm/kvm_vcpu_sbi.h > > > > +++ b/arch/riscv/include/asm/kvm_vcpu_sbi.h > > > > @@ -69,6 +69,7 @@ extern const struct kvm_vcpu_sbi_extension vcpu_s= bi_ext_ipi; > > > > extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_rfence; > > > > extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_srst; > > > > extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_hsm; > > > > +extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_dbcn; > > > > extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_experiment= al; > > > > extern const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_vendor; > > > > > > > > diff --git a/arch/riscv/include/uapi/asm/kvm.h b/arch/riscv/include= /uapi/asm/kvm.h > > > > index 917d8cc2489e..60d3b21dead7 100644 > > > > --- a/arch/riscv/include/uapi/asm/kvm.h > > > > +++ b/arch/riscv/include/uapi/asm/kvm.h > > > > @@ -156,6 +156,7 @@ enum KVM_RISCV_SBI_EXT_ID { > > > > KVM_RISCV_SBI_EXT_PMU, > > > > KVM_RISCV_SBI_EXT_EXPERIMENTAL, > > > > KVM_RISCV_SBI_EXT_VENDOR, > > > > + KVM_RISCV_SBI_EXT_DBCN, > > > > KVM_RISCV_SBI_EXT_MAX, > > > > > > You just broke a user/kernel ABI here, why? > > > > The KVM_RISCV_SBI_EXT_MAX only represents the number > > of entries in "enum KVM_RISCV_SBI_EXT_ID" so we are not > > breaking "enum KVM_RISCV_SBI_EXT_ID" rather appending > > new ID to existing enum. > > So you are sure that userspace never actually tests or sends that _MAX > value anywhere? If not, why is it even needed? > > thanks, > > greg k-h Regards, Anup