Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp259958pxm; Tue, 22 Feb 2022 22:51:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJwFs4sAocdudo3babWf8jMkp4PYhLA2HhgAqZzqxrqM+vCN9qgKOgi9mNNFmn2hSlY4W59v X-Received: by 2002:a05:6402:51d2:b0:412:e48e:51 with SMTP id r18-20020a05640251d200b00412e48e0051mr18922114edd.220.1645599060603; Tue, 22 Feb 2022 22:51:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645599060; cv=none; d=google.com; s=arc-20160816; b=UPzAiTvVH2Soimn2+JFS3QdmgcPBPxMch99cm6sl4+Kw5bMHRSOAL/Zxvyb+jwzRcA fZCKGWYawbVZ1HJCxmhi46HKO7P/z7efV0+tm9IcKbvJSftt8LSQ4lbDA9Dwfg7MGVnC luDoHqwKr+WUvnDJ2GWNzSZYL961gzKfhvL2fl5GmCU9BPnT9K31DNWX9rXQ9JE8o/r6 LO0Cn3RRBycU+crFYRczQxKV3goHEKUp3pZ516k2ZiplpJWQS3C8xhOR1Y7jSC9Hjr8P xeWtRHWsQYLVP8z15ByUAMHyXKPI/kHTjihGy8U5CbapE6N2nqMXDImVwmu1pZwCG1TS lxqg== 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=x/iZxI5gJtmmVE2EU9ERKSSqKXLjBqX4XWhFsi12fm4=; b=lcRqropj7fJ/xfzSUcwgFSBdS9yTUrauo5LBl6Y4ZVjtg4+CLRG5eHFvUTHiIfiH/d nnZOs8eJrz0DHe+2cgE0LmN7Poo4z8jlgbIuA7UIpGZVtkbM2+uUgRqvlgP9ZmOviwms /yCPqwbj15EYZMG7prKS3bCZ77dNqruscruF4naXGAHBOizQEqkdMPllg3mA2CI3T8Vm dNXZEu6xmHpTYpk+hStBCjXDgRxeAvvvWuTcKPbC6nXk5FCgPgRAWiw4DjMH7jiUNywG 19qjoqIx9SN8kZpIT5C3P9M/jVeSDCGewv0rdvKXwCwYoyNKmJrhq1RMvH9s9saIYLkD a8lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@atishpatra.org header.s=google header.b=iMqGMltc; 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 nc11si12395381ejc.692.2022.02.22.22.50.35; Tue, 22 Feb 2022 22:51:00 -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=iMqGMltc; 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 S237609AbiBWDhp (ORCPT + 99 others); Tue, 22 Feb 2022 22:37:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234607AbiBWDhn (ORCPT ); Tue, 22 Feb 2022 22:37:43 -0500 Received: from mail-yw1-x112f.google.com (mail-yw1-x112f.google.com [IPv6:2607:f8b0:4864:20::112f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83D5513EB9 for ; Tue, 22 Feb 2022 19:37:15 -0800 (PST) Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-2d625082ae2so196720347b3.1 for ; Tue, 22 Feb 2022 19:37:15 -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=x/iZxI5gJtmmVE2EU9ERKSSqKXLjBqX4XWhFsi12fm4=; b=iMqGMltcaywF4JIrOBiSfBrO1ZiTpm42kZ8q96IXPD5P8wyMFaebGsFazuGUrLW8/M saOIHcsTHJlWkpFpUC6TbGA3KpXDYMQZm0eKYNi8Cmc0lEjYhTvC4/QLjpIVxgiIgYFH 6d5BR6Wkf9oa82BMhVEKs8uf98U5ebixJldT0= 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=x/iZxI5gJtmmVE2EU9ERKSSqKXLjBqX4XWhFsi12fm4=; b=sndflnTRmCB3HJM2SJmX7W9Nv2rmorCaYdvFrA899Tlt82R8ltg5dvCa4RLyw9dQdI zETVj6YjD7fAiXDdN8K77eZc9e50h1SwfexjYBcL6vpYPHAUmX2SGtAHwky9IQc8BnVc E3X6GqPZ2tWAPWPFm1AQiclYg2k8K6J9zTPZRxY0LCBDJa9gOIg3KznQXgE93f3qV7fR i2Yvy/Ega/Oqof4EZB4EVHn4FJf6556ge+NcDr9vH/Gkt29bEDSZLQobprdvJFSLlUoW FsPG5XYJWNjkKIFKOK6o6mPutBvquET+ev0bGbG2nPbv5tf4hp3DlrMIFg5PHW41w1AI Nfyg== X-Gm-Message-State: AOAM532U5p4i9R6l2TwVjV/olynNX5Ee8ubiSmiIaCmOjyrcDRXfle61 s50C54kUOk58aBbZRPRkPejL8a6YNynSdEUUd56r X-Received: by 2002:a81:844c:0:b0:2d6:920b:f959 with SMTP id u73-20020a81844c000000b002d6920bf959mr26893176ywf.443.1645587434737; Tue, 22 Feb 2022 19:37:14 -0800 (PST) MIME-Version: 1.0 References: <20220201082227.361967-1-apatel@ventanamicro.com> <20220201082227.361967-7-apatel@ventanamicro.com> In-Reply-To: <20220201082227.361967-7-apatel@ventanamicro.com> From: Atish Patra Date: Tue, 22 Feb 2022 19:37:04 -0800 Message-ID: Subject: Re: [PATCH 6/6] RISC-V: KVM: Implement SBI HSM suspend call 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:24 AM Anup Patel wrote: > > The SBI v0.3 specification extends SBI HSM extension by adding SBI HSM > suspend call and related HART states. This patch extends the KVM RISC-V > HSM implementation to provide KVM guest a minimal SBI HSM suspend call > which is equivalent to a WFI instruction. > > Signed-off-by: Anup Patel > --- > arch/riscv/kvm/vcpu_sbi_hsm.c | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/arch/riscv/kvm/vcpu_sbi_hsm.c b/arch/riscv/kvm/vcpu_sbi_hsm.c > index 1ac4b2e8e4ec..239dec0a628a 100644 > --- a/arch/riscv/kvm/vcpu_sbi_hsm.c > +++ b/arch/riscv/kvm/vcpu_sbi_hsm.c > @@ -61,6 +61,8 @@ static int kvm_sbi_hsm_vcpu_get_status(struct kvm_vcpu *vcpu) > return -EINVAL; > if (!target_vcpu->arch.power_off) > return SBI_HSM_STATE_STARTED; > + else if (vcpu->stat.generic.blocking) > + return SBI_HSM_STATE_SUSPENDED; > else > return SBI_HSM_STATE_STOPPED; > } > @@ -91,6 +93,18 @@ static int kvm_sbi_ext_hsm_handler(struct kvm_vcpu *vcpu, struct kvm_run *run, > ret = 0; > } > break; > + case SBI_EXT_HSM_HART_SUSPEND: > + switch (cp->a0) { > + case SBI_HSM_SUSPEND_RET_DEFAULT: > + kvm_riscv_vcpu_wfi(vcpu); > + break; > + case SBI_HSM_SUSPEND_NON_RET_DEFAULT: > + ret = -EOPNOTSUPP; > + break; > + default: > + ret = -EINVAL; > + } > + break; > default: > ret = -EOPNOTSUPP; > } > -- > 2.25.1 > Reviewed-by: Atish Patra -- Regards, Atish