Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1582363pxb; Wed, 2 Feb 2022 08:05:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJwGAmC+HgdM+KCWfsT/3AvN2Po+WyFn6SdzQQT5X73QqdLgekJ+9Mic4dh4unnpU6NZ3Nky X-Received: by 2002:a63:8ac9:: with SMTP id y192mr24627326pgd.409.1643817942056; Wed, 02 Feb 2022 08:05:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643817942; cv=none; d=google.com; s=arc-20160816; b=AjI3DmpoxpkvJM4ke5bvI1/otDCgpfdmdBcreAhnaPqC4ynBWkdnfe5IgNUqTLLhAf k2MmdRcZHncGoyXUkDq+2r+pdJkcayOYt7jXKAF2MlA0EVtlPCqnhMB+Eb6mkOXXtO3a 1gxoQcEEdDoHCj0V88VUILaSeg3wLZzipxElG0EIKTj8qebG3sM+EJvTxTTu5DnO6iou 4ajARzWf005cHEEkVo/2aegey3CZ3pf2j9n6+ObWy7aY4Qdd/tNi+VJzxS5ceceiK/Nm X4fxKpDrZye0U7KiCFasahLU/4LgzapcCIjH78E9rKPdtxq82Xxj653oYw1jzPVT/VUe hulQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sWXOnh6V8JfeAKPCTBsP63fO+aHlS1gzo9x3i/6GE6E=; b=gq8keHX9sf1ZVyu4J8aS+hSAkxgxD6kXb86UH1Vy1gj9OE7bfbDaHld64FVqYOUW77 QUupFLIdaHwI5BMj92jRjhBgg6iw1qsQfUw9Aj/iNaaALXCCMjyYwrF5IzL+6iBaRwni xPkMZXGM/fSlJw4ootd4Hj3Ssyb5QoGf6wlenf4qYU00G1b4CLzxqcXlxDe8J/0mwniN x/5CV7h2GzsUMT5r43nU8zK3VSW0NA4v0LEcNe7XQw7RtnQsXmZSPuw0D8AkbqY7Pt+v LgVP9stsVB5qmvrkFPJstLpsrgDG/IecXFT2JLd15pSv/LL/j+fStsHDUZqRo2knymM+ 6K2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=ALK239EP; 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 m20si20945036pfk.347.2022.02.02.08.05.28; Wed, 02 Feb 2022 08:05:42 -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=@ventanamicro.com header.s=google header.b=ALK239EP; 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 S235452AbiBAIXx (ORCPT + 99 others); Tue, 1 Feb 2022 03:23:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235084AbiBAIXt (ORCPT ); Tue, 1 Feb 2022 03:23:49 -0500 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 452D3C061741 for ; Tue, 1 Feb 2022 00:23:49 -0800 (PST) Received: by mail-ed1-x534.google.com with SMTP id c24so32819421edy.4 for ; Tue, 01 Feb 2022 00:23:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sWXOnh6V8JfeAKPCTBsP63fO+aHlS1gzo9x3i/6GE6E=; b=ALK239EPhhbKnBQAarVre2qSAgyqxLhsur30HkoKRHTo2K0etUwzSjub/fA46wqZ3v sffzujqr51nXRa0RVA/w900IKQe/5K2nW2xeUvbM3z5HVB5Mww8SVdM9ksqaIsHamZ4F DxgZjgkJQCPX8kyilf7tT711OgwoPLhiSVk70Dcjegj9YfCfMh5+JLK84AHcj/z+mk94 Q0Hg4lUV4uGHlNIDmfMxJXAFgtaX3aHORO9Ip6O6ajm47HWzYDDWL2+FO8poRRpKctLj zc3YsSLYUvtQSpoVIGfsG/Au+zCgQDvl5B09DcBGKkJVMPlAooidYwHY9OA4Affd9kMD TlyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sWXOnh6V8JfeAKPCTBsP63fO+aHlS1gzo9x3i/6GE6E=; b=cRGysEqHfHSV3W9Eoh2VYTwd9hzlAosxJU/mYH3P/T4GzeMAT/Ud9ih63qza5L048r 0TRS5cDDYU4Lid32R0PFXxCW1xQVkH4WCFBqH9JcvFopQ2nID7K0a+m/5FFD3UjT60a4 jqGxODJvLFpiSUGEYkZShUDQaflBvO4/1BFq0WlAeX+qZRCB4fRcGWQJI6QdXB4LQNsb J6MsKzJfxsp30S0pDASK7F+Kd7n/N99sFketaEE3hFsiNIuLvM/ToVtj+1oz4gxhjWvo frm7ji7OO7QrKSNKNip1fHYK+DhioAAGWw6+/vAbnF82QBiDqkzL5EonC3UcB5ePvrYo 77yg== X-Gm-Message-State: AOAM530JTS57UONWtNaWl2NcStvNcRb1hM49BuOytDet381nkQ7Zgi8H zMdbxV901cd7pLB/Qee3Zx1J1A== X-Received: by 2002:aa7:d553:: with SMTP id u19mr24595529edr.298.1643703827873; Tue, 01 Feb 2022 00:23:47 -0800 (PST) Received: from localhost.localdomain ([122.179.76.38]) by smtp.gmail.com with ESMTPSA id w8sm14312133ejq.220.2022.02.01.00.23.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 00:23:47 -0800 (PST) From: Anup Patel To: Paolo Bonzini , Atish Patra Cc: Palmer Dabbelt , Paul Walmsley , Albert Ou , Alistair Francis , Anup Patel , kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel Subject: [PATCH 2/6] RISC-V: KVM: Add common kvm_riscv_vcpu_sbi_system_reset() function Date: Tue, 1 Feb 2022 13:52:23 +0530 Message-Id: <20220201082227.361967-3-apatel@ventanamicro.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220201082227.361967-1-apatel@ventanamicro.com> References: <20220201082227.361967-1-apatel@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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