Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp613643rdg; Tue, 10 Oct 2023 23:33:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEmnP+FSC7vmVkBS+AomCAjnwA+vZzFrmF0w6Y1jkY7MmD5Elj7zet2kdZ4YfwYNg/vQSYg X-Received: by 2002:a17:90b:f84:b0:27c:f4a9:7e20 with SMTP id ft4-20020a17090b0f8400b0027cf4a97e20mr4795619pjb.15.1697005981393; Tue, 10 Oct 2023 23:33:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697005981; cv=none; d=google.com; s=arc-20160816; b=ENABgWpeBYTnkjME4KqC6U9Jc7ehoi3YrL/oSxFi3tmHJEJ8rhipD0/AsKASI8KdGE Ln2PA/W2lLt4kyPCYLYuaYoSJ8820N9NdelmLPktp5OtdLpUo8JJERA8foNOCY//nNK7 jAksHOLbXPHDPzll6b0ekoG9Dq0lBrpnFyG+qboLCEbb0x3R4UZELiBVrAZ5LXF1LvUn Lp1PLmfsNqEjdtCK68m8bcVIvaaabaHjtU+a6gZG4MusckjhmFvlHBdrAAxGp5hUXuh7 y4TWPt/R5Ze9tW6pc7ax0blL2YBfhHEHpjmXqFLYANyTnY0oO5UqitQMrunAXTfssXrG X7+g== 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=qlCvzn9D9MWfXzyAjQXrd2l33CVlRWaoX+EsCqMd6ps=; fh=JyL8+fJr4BsolHUmcm+dYi0xCmNZZ71zno4Ij1nE8wE=; b=RQn06hqGXjiLs2NGnv2nZLuLK59CUxiTGd0bPtue3rwSoIqTOS1lIojc9JjTwSWNHu /mVDd37J7xxLyn8ZmTc8aoX5GSqOfHe2GFZSsM62t9pIeoPPkef3QBih80iE6qUeyjSj A5JYq3w4okvhFfswpgq+04SHQi9i5+chg+gR66efpeQ4Iv1kiQaOGMT/Yd9YIQQhzTMi GOZZDHVp6MKM5mnfVDVf3vXq+5OR2uv1no4r5juhLHQbGUUI8WxJ4yp1hvB99XhRKEyx 8YOp7rpCqzs/97e9cLPwyDBPQGaTOJnck5/giXxz5g93+Fm+y2VxmhWdx/RzsH/nEP6l FCug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=kWTWVPK7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id w12-20020a17090a4f4c00b002773152a294si15479936pjl.80.2023.10.10.23.33.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 23:33:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=kWTWVPK7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id CD147801B812; Tue, 10 Oct 2023 23:32:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344315AbjJKGco (ORCPT + 99 others); Wed, 11 Oct 2023 02:32:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344448AbjJKGcn (ORCPT ); Wed, 11 Oct 2023 02:32:43 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABF0D9B for ; Tue, 10 Oct 2023 23:32:40 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-692d2e8c003so484211b3a.1 for ; Tue, 10 Oct 2023 23:32:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1697005960; x=1697610760; 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=qlCvzn9D9MWfXzyAjQXrd2l33CVlRWaoX+EsCqMd6ps=; b=kWTWVPK7N9NCNf2HZ3Fyp42qChTUEHUHU97/4FONyjQgtNtbeeDXBEMNrp4zfUlB2x vX8T9j9s5s/ARkEB/UTWO0sisG0aSIWSqSzC4PvABUFj0ZSX7YtcnAA3sPm/ccNFz1dn Cch+OPNt05lppQURTmvKrfRsnNHKAK2a9/lZzh5RKgkp58iWhKD9slxYcvPXpEznkydo BwuPnbCUXdYJEG6R1oOGbPVpXS9PA9eEBdiFUoU2yfd7jwNOnoF1L81rbqLlouQUA/kc fAi5QEBKkuyqfXDx0cyrFI2nxm61QRBAgtxwQ49npw0Oq4dWd2GyhXTcSgYJ8R4USj+D Vd1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697005960; x=1697610760; 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=qlCvzn9D9MWfXzyAjQXrd2l33CVlRWaoX+EsCqMd6ps=; b=GlqW4ULZ8xMHFXy5jwpdfoRZswhXoL0S9bCoKT8A21ARYd7jUvuk7E40Uajv/7AY9v UHGRJ1XTMWWqdRaNlSxSGnenw7cmc+3Hu63mFL8D8FypVZQw58b8N4ntSgbhbovj68u0 nGCj7O9JKz26q2JMESbAjR62nnXNhik8fyPTENVzEzVNxQeiQXdW/0ZkWr8ANl+hRAaP I7ImYaGsXLPl1B1EkrR8pwzflWRFaJZ9SqwTY2GjFNfLwdElCIKaT+vU1AE2CqUJz+jE BVZUdZvmajJsvvdVXLQHw5BgDSr34LwQZVSzQETLL0DGtgoEJ1TZXqVK4SG00risAaVv Vhug== X-Gm-Message-State: AOJu0YwDqaNSvnxzEKRGpM1r3QqpySD9tesRGcezsUXz/Y2+BIiwjzaH 569KBWz+9aSHxXVZ6U7/vnOzLPmeTwO9OgkHJ7B1JA== X-Received: by 2002:a17:90b:4a02:b0:277:61d7:78be with SMTP id kk2-20020a17090b4a0200b0027761d778bemr24784754pjb.14.1697005960055; Tue, 10 Oct 2023 23:32:40 -0700 (PDT) MIME-Version: 1.0 References: <20231010170503.657189-1-apatel@ventanamicro.com> <20231010170503.657189-4-apatel@ventanamicro.com> <2023101048-attach-drift-d77b@gregkh> In-Reply-To: <2023101048-attach-drift-d77b@gregkh> From: Anup Patel Date: Wed, 11 Oct 2023 12:02:30 +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.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Tue, 10 Oct 2023 23:32:55 -0700 (PDT) X-Spam-Level: ** 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. > > > 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. This is more about providing flexibility to KVM user-space which allows it to manage guest console devices. > > > > > 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/include= /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_sbi_e= xt_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_experimental; > > 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/uap= i/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. > > thanks, > > greg k-h Thanks, Anup