Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp47032pxm; Tue, 22 Feb 2022 16:18:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJzqJ0o3swKyymYVg6NQz35leeeJkcq0IdezkYDWIWObc8afPWJHr5xFcKnTY7p1QjBfjCnY X-Received: by 2002:a62:1c09:0:b0:4e1:716c:7614 with SMTP id c9-20020a621c09000000b004e1716c7614mr27262497pfc.84.1645575513982; Tue, 22 Feb 2022 16:18:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645575513; cv=none; d=google.com; s=arc-20160816; b=UiwRhXfUPe+/09oXDEtJonqkHxS8kFEfOikRGtat5h0oykDZUaQ/9oIZMyTegDus5K j59Xbx4OBXMFEukK9KGIcpKar0jn0WdROdCh5+ReUL5fgm+ABX5rnVgZzB3UfJcbe0uu ZsT4dC05ZqruoaHSgE5r+8ujTw3wyr6GyRB9C65a6G+x+sww4dEI+t/9NF5+sXgQyv0N dRSlvoXSffURf/9f3AUi/IMPyY+ZBnbj/0qLaAQQtzIcUnqqwkjOUHOWfxLC96uuIX60 SMTCiAHRyauPWYaTBJJzfTqkKUxywjiCncpHk3c28ikLip9fTrUPIHHcSiDrGY8IPbKf nFTA== 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=Y1Ih26MrSKGdWJCNbpIUtuX1M042QCw2P53iJFNC+sE=; b=PYmX0058lsQ0O/KlTm3A8EdAMVUXJaPRnEArtZLQ7jgDyelIQZdDNY12l+Skw2cbKg gRVtu19H5fY5bk9CP4Kn5ciYtvp20SrlNOilw6f4TF4s1kHnpnHLoT+HXgIW1SY1raDx ETkrkFApK3qTtoBr5VDollnDzNqHmVseXIHbIkGNxM2OWb4lBaHokwooYpCmzvCvySuU EU/KIi+JZgGkv3PASWyr4LSJCHnU6fhkFRsrTLyIMiGbHLfoAa3vR4NWVWJUwBfgL3kW 928dxImwW+XSyKD5XKsYHFlAxrwt+x6vx0l7lafcHfQELQIEcsoHSY2xAyk37nKYq2c4 3Dtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@atishpatra.org header.s=google header.b=H6cezHFO; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t188si8854332pgc.856.2022.02.22.16.18.17; Tue, 22 Feb 2022 16:18:33 -0800 (PST) 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=@atishpatra.org header.s=google header.b=H6cezHFO; 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 S233005AbiBVXzp (ORCPT + 99 others); Tue, 22 Feb 2022 18:55:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236325AbiBVXzg (ORCPT ); Tue, 22 Feb 2022 18:55:36 -0500 Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11EA137020 for ; Tue, 22 Feb 2022 15:55:06 -0800 (PST) Received: by mail-yb1-xb2f.google.com with SMTP id y189so22973874ybe.4 for ; Tue, 22 Feb 2022 15:55:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=atishpatra.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Y1Ih26MrSKGdWJCNbpIUtuX1M042QCw2P53iJFNC+sE=; b=H6cezHFOFMFRwhzFTu/eU/s08XZwwwOv1ttTWJy9ZJ0fwuhHjou0ABho7Cbc+55Cuq fqQybw7pZ5TkFfNHGqHttY4R/ycLZZKjQrVHnQVSW8ue7Z+AosMf5ZpqVpzsNXlxk1JO kkvNXbDj1+4do+IXR6IJWMlOyXf5DcoJKaK8I= 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=Y1Ih26MrSKGdWJCNbpIUtuX1M042QCw2P53iJFNC+sE=; b=kPT3+++pdj3b7frOA7dYk25mIYa5NGRydqjS4DhRxOYUrGrtjh1dZEeKjCDneaM1lC 6D5fiAyBwLEiqbO06hi9P2BTeh6cpSO+JDeldlmDSrABfalI9kDwrvmyHEYD2i1AmytX 6Vmr0W1bFdj+X1tnyNw5fw4jkkt4fYiaieIPj3/Lhk6LO3DgnSjNOWx56Y2lw5dggSY8 MpbAgnlnnVMgZJET8ffIAjpVfOAavQiEVFnlAVTdBCWfHp240rSWx3JWFsnlNfnvBnFF bGMdDtRkoV9qGBIIiXWjerEWYiaj876Y4HmQqnvTagQXyqxyD3sEMvn9wg4k72/Oi4A8 rwJQ== X-Gm-Message-State: AOAM533Ws8eVjtfCaw+WHjoc+prFHKzxj/Oi3HlOS8cmvzHxuKg2/Kaz +8g83glFTKQz1Q47EK1YGTKOwJK1lQ++xjqxL5zX X-Received: by 2002:a25:908f:0:b0:624:a2d8:9f81 with SMTP id t15-20020a25908f000000b00624a2d89f81mr9785594ybl.417.1645574105992; Tue, 22 Feb 2022 15:55:05 -0800 (PST) MIME-Version: 1.0 References: <20220201082227.361967-1-apatel@ventanamicro.com> <20220201082227.361967-3-apatel@ventanamicro.com> In-Reply-To: <20220201082227.361967-3-apatel@ventanamicro.com> From: Atish Patra Date: Tue, 22 Feb 2022 15:54:55 -0800 Message-ID: Subject: Re: [PATCH 2/6] RISC-V: KVM: Add common kvm_riscv_vcpu_sbi_system_reset() function To: Anup Patel Cc: Paolo Bonzini , Palmer Dabbelt , Paul Walmsley , Albert Ou , Alistair Francis , Anup Patel , KVM General , kvm-riscv@lists.infradead.org, linux-riscv , "linux-kernel@vger.kernel.org List" Content-Type: text/plain; charset="UTF-8" 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_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Tue, Feb 1, 2022 at 12:23 AM Anup Patel wrote: > > We rename kvm_sbi_system_shutdown() to kvm_riscv_vcpu_sbi_system_reset() > and move it to vcpu_sbi.c so that it can be shared by SBI v0.1 shutdown > and SBI v0.3 SRST extension. > > Signed-off-by: Anup Patel > --- > arch/riscv/include/asm/kvm_vcpu_sbi.h | 3 +++ > arch/riscv/kvm/vcpu_sbi.c | 17 +++++++++++++++++ > arch/riscv/kvm/vcpu_sbi_v01.c | 18 ++---------------- > 3 files changed, 22 insertions(+), 16 deletions(-) > > diff --git a/arch/riscv/include/asm/kvm_vcpu_sbi.h b/arch/riscv/include/asm/kvm_vcpu_sbi.h > index 04cd81f2ab5b..83d6d4d2b1df 100644 > --- a/arch/riscv/include/asm/kvm_vcpu_sbi.h > +++ b/arch/riscv/include/asm/kvm_vcpu_sbi.h > @@ -28,6 +28,9 @@ struct kvm_vcpu_sbi_extension { > }; > > void kvm_riscv_vcpu_sbi_forward(struct kvm_vcpu *vcpu, struct kvm_run *run); > +void kvm_riscv_vcpu_sbi_system_reset(struct kvm_vcpu *vcpu, > + struct kvm_run *run, > + u32 type, u64 flags); > const struct kvm_vcpu_sbi_extension *kvm_vcpu_sbi_find_ext(unsigned long extid); > > #endif /* __RISCV_KVM_VCPU_SBI_H__ */ > diff --git a/arch/riscv/kvm/vcpu_sbi.c b/arch/riscv/kvm/vcpu_sbi.c > index 78aa3db76225..11ae4f621f0d 100644 > --- a/arch/riscv/kvm/vcpu_sbi.c > +++ b/arch/riscv/kvm/vcpu_sbi.c > @@ -79,6 +79,23 @@ void kvm_riscv_vcpu_sbi_forward(struct kvm_vcpu *vcpu, struct kvm_run *run) > run->riscv_sbi.ret[1] = cp->a1; > } > > +void kvm_riscv_vcpu_sbi_system_reset(struct kvm_vcpu *vcpu, > + struct kvm_run *run, > + u32 type, u64 flags) > +{ > + unsigned long i; > + struct kvm_vcpu *tmp; > + > + kvm_for_each_vcpu(i, tmp, vcpu->kvm) > + tmp->arch.power_off = true; > + kvm_make_all_cpus_request(vcpu->kvm, KVM_REQ_SLEEP); > + > + memset(&run->system_event, 0, sizeof(run->system_event)); > + run->system_event.type = type; > + run->system_event.flags = flags; > + run->exit_reason = KVM_EXIT_SYSTEM_EVENT; > +} > + > int kvm_riscv_vcpu_sbi_return(struct kvm_vcpu *vcpu, struct kvm_run *run) > { > struct kvm_cpu_context *cp = &vcpu->arch.guest_context; > diff --git a/arch/riscv/kvm/vcpu_sbi_v01.c b/arch/riscv/kvm/vcpu_sbi_v01.c > index 2ab52b6d9ed3..da4d6c99c2cf 100644 > --- a/arch/riscv/kvm/vcpu_sbi_v01.c > +++ b/arch/riscv/kvm/vcpu_sbi_v01.c > @@ -14,21 +14,6 @@ > #include > #include > > -static void kvm_sbi_system_shutdown(struct kvm_vcpu *vcpu, > - struct kvm_run *run, u32 type) > -{ > - unsigned long i; > - struct kvm_vcpu *tmp; > - > - kvm_for_each_vcpu(i, tmp, vcpu->kvm) > - tmp->arch.power_off = true; > - kvm_make_all_cpus_request(vcpu->kvm, KVM_REQ_SLEEP); > - > - memset(&run->system_event, 0, sizeof(run->system_event)); > - run->system_event.type = type; > - run->exit_reason = KVM_EXIT_SYSTEM_EVENT; > -} > - > static int kvm_sbi_ext_v01_handler(struct kvm_vcpu *vcpu, struct kvm_run *run, > unsigned long *out_val, > struct kvm_cpu_trap *utrap, > @@ -80,7 +65,8 @@ static int kvm_sbi_ext_v01_handler(struct kvm_vcpu *vcpu, struct kvm_run *run, > } > break; > case SBI_EXT_0_1_SHUTDOWN: > - kvm_sbi_system_shutdown(vcpu, run, KVM_SYSTEM_EVENT_SHUTDOWN); > + kvm_riscv_vcpu_sbi_system_reset(vcpu, run, > + KVM_SYSTEM_EVENT_SHUTDOWN, 0); > *exit = true; > break; > case SBI_EXT_0_1_REMOTE_FENCE_I: > -- > 2.25.1 > Reviewed-by: Atish Patra -- Regards, Atish